248 Commits

Author SHA1 Message Date
Boris Bobrov
a5dae0dbc2 Commit session after alembic updates have finished
After alembic updates we need to add foundations. The tables to add
foundations to are created as part of dbupdate process. For some reason
Alembic doesn't commit a session in the end. Because the session is not
commited, the tables do not really get created. And because of that,
foundations fail.

The solution is to commit the session after alembic updates.
2017-04-01 21:07:01 +03:00
Andrew Browning
2d0870e061 Fix trivial spelling and spacing error in cli help 2017-03-01 01:34:04 -05:00
Boris Bobrov
f86dafe2a0 Merge remote-tracking branch 'spechards-mediagoblin/master'
Conflicts:
	mediagoblin/submit/lib.py -- happened because of creator->actor
                                     change

Fixes issue #915
2017-01-29 19:09:06 +03:00
Loic Dachary
6c0678576a Fix #928 - cleanup to avoid duplicated get_upload_file_limits
Signed-off-by: Loic Dachary <loic@dachary.org>
2016-07-25 03:48:33 +03:00
Berker Peksag
6b6d14f48a Replace raw_input with six.moves.input
Fixes #5441
2016-04-02 20:48:04 +03:00
Christopher Allan Webber
e3cfc9a84f dbupdate: Correctly handle plugin foundations
* mediagoblin/gmg_commands/dbupdate.py (run_foundations):
  When adding a plugin's foundations, correctly append both
  the name and the foundations in a tuple to the list.
  This prevents errors.
2016-03-26 11:39:08 -07:00
Christopher Allan Webber
385b5b44f5 Removing erronously installed print statement.
* mediagoblin/gmg_commands/alembic_commands.py (FudgedCommandLine.main):
  Removed call to print.
2016-03-26 11:39:07 -07:00
Christopher Allan Webber
406058b340 Allow for passing in --with-plugins to the alembic gmg subcommand.
This allows plugin writers to easily take advantage off alembic's migration
autogeneration support.

* mediagoblin/gmg_commands/alembic_commands.py: Adjusted imports.
  (FudgedCommandLine.main, parser_setup): Add support for importing
  plugins when --with-plugins is passed in.
2016-03-26 11:39:07 -07:00
Christopher Allan Webber
f25b476202 Only run sqlalchemy-migrate migrations if we have to; separate foundations
The goal is to get things to the point where Alembic can run on its own
for new databases and initialize the whole database on its own.  There
are risks to not doing so, see #5413 for details.

There's a lot more here that could removed or cleaned up once
sqlalchemy-migrate is *completely* removed in the future.

* mediagoblin/db/migration_tools.py (MigrationManager.foundations):
  Removed attribute.
  (MigrationManager.populate_table_foundations): Removed method.
  (MigrationManager.init_or_migrate): Removed call to deprecated method.
  (populate_table_foundations): New function, refactored from former
  MigrationManager method of same name.

* mediagoblin/gmg_commands/dbupdate.py: Import populate_table_foundations.
  (DatabaseData.foundations): Remove attribute.
  (DatabaseData.make_migration_manager): Adjust instantiation of
  MigrationManager.
  (gather_database_data): Move out the work of building up foundations data.
  (run_foundations): New method, incorporating logic for gathering and
  running foundations which was previously spread across other
  functions and methods.
  (run_alembic_migrations): Remove deprecated comment.
  (run_dbupdate): Only run sqlalchemy migrations if we have to.
  Also run run_foundations if we are setting up this database for the
  first time.
  (sqam_migrations_to_run): New method.
2016-03-26 11:39:07 -07:00
Christopher Allan Webber
05879c1c76 dbupdate updates to use plugin migrations if available
This makes use of the recently added "build_alembic_config" tool and
removes AlembicMigrationManager.

* mediagoblin/db/migration_tools.py (AlembicMigrationManager): Removed.
* mediagoblin/gmg_commands/dbupdate.py (run_alembic_migrations):
  Adjusted to use recently added build_alembic_config tool.
2016-03-26 11:39:07 -07:00
Christopher Allan Webber
6e9041aa4b Add build_alembic_config, use it to add plugin migrations to alembic config 2016-03-26 11:39:07 -07:00
Boris Bobrov
17aaab6907 Fix module name for gmg alembic command
gmg_commands.alembic attempted to import from `alembic`. On python2.7
it resulted in import from itself.

Rename alembic.py to alembic_commands.py and fix references to
gmg_commands.alembic.
2016-03-08 18:23:45 +03:00
Christopher Allan Webber
4efa61c16a Commentary on where this hack on detecting no subcommand to Alembic comes from 2016-03-05 16:28:41 -08:00
Christopher Allan Webber
399272eea5 Add "gmg raw_alembic" command.
This allows you to dispatch to the "alembic" command line tool properly,
but properly respecting MediaGoblin's own configuration.
2016-03-03 09:31:00 -08:00
Christopher Allan Webber
d61778a489 Switch from Paste for serving to Waitress
Incredibly, it looks like none of our documentation has to change taking
this route...!
2016-02-19 10:22:14 -08:00
Christopher Allan Webber
f485d55f81 Add a TODO to rename run_all_migrations to run_legacy_migrations 2016-01-11 07:14:33 -08:00
Boris Bobrov
2b68834c44 Enable alembic as the main tool for migrations
Enable alembic for all migrations and limit the max number of
sqlalchemy-migration migration. All new migrations must now be in
Alembic!
2016-01-11 07:14:33 -08:00
Boris Bobrov
8da8c0ac2d Fix various style issues
Sorry, cannot look at them without urge to fix
2016-01-11 07:14:33 -08:00
Ben Sturmfels
be2621a43c Prevent unhandled exception on non-existant user.
These changes bring `makeadmin` and `changepw` in-line with the approach used in `deleteuser`.

I've also made the error messages more consistent: list the username and full sentences.
2015-11-05 14:49:36 -06:00
Jessica Tallon
0f3bf8d4b1 Collection changes and migration for federation
- Adds a "type" column to the Collection object and allows the
CollectionItem model to contain any object.
- Changes "items" to "num_items" as per TODO
- Renames "uploader", "creator" and "user" to a common "actor" in most places
2015-10-07 14:40:44 +02:00
Jessica Tallon
b4997540dc Fix some unit tests and bugs
This fixes a lot of the issues with the LocalUser changes that were
merged recently. There was a problem where the attributes of LocalUser
were not being eagerly loaded and because the Session was detached an
exception was being raised when they were accessed.

This also fixes some typo's which were introduced.

Finally this adds a temporary fix for a potential SQLAlchemy bug, this
is a bug where doing:

    User.query.filter(LocalUser.username == "some_username").first()

does NOT yeild a user with the username "some_username" but all users
on the site. The temp fix is to just query the LocalUser, this should
be resolved when bug is confirmed and fixed upstream.
2015-08-24 21:07:06 +02:00
Jessica Tallon
d88fcb03e2 Change codebase to query or create correct User model
The code base had many references to User.username and other
specific to LocalUser attributes as that was the way it use to exist.
This updates those to query on the generic User model but filtering
by attributes on the LocalUser.
2015-07-31 15:15:24 +02:00
Berker Peksag
47a2ab9cfc Return non-zero exit code if the command cannot be completed successfully.
Fixes #5084
2015-07-22 10:52:37 +03:00
Berker Peksag
896d00fbf2 Change all unicode() calls with six.text_type().
Fixes #5329.
2015-06-25 22:24:03 +03:00
Jessica Tallon
a02de38f91 Let parser handle typing for deletuser command 2015-01-20 12:24:13 +00:00
Christopher Allan Webber
a4768df0ca Context objects now use a contextmanager (and update gmg shell to use it)
This means that we have a really convenient way to make sure that you
have a context/request that threads its way through the application,
where everything needed gets "shut down" appropriately by the end.

You always get a context object via a context manager!  And by the time
you're done with it, things should be cleaned up.
2014-12-03 15:40:57 -06:00
Christopher Allan Webber
f08e31522d Make "gmg shell" work with the new globals-less setup 2014-12-03 15:40:57 -06:00
Christopher Allan Webber
692e8e7848 This import_export stuff is mongodb days leftovers. Removing!
This commit sponsored by Ray Redd.  Thanks!
2014-11-26 16:44:28 -06:00
Berker Peksag
9d85dcdf11 Fix unicode handling in "gmg addmedia". 2014-11-22 18:12:19 +00:00
Christopher Allan Webber
4c03d45f6a Make a mediagoblin.ini file for the user if needed.
This is to prevent our docs from confusing people in this
transitionary time period...
2014-10-10 19:35:09 -05:00
Berker Peksag
b36c84e68a Port "gmg batchaddmedia" command to Python 3. 2014-10-02 20:18:29 +03:00
Christopher Allan Webber
0c78f41ac7 Switch print statement to print function 2014-09-24 09:32:13 -05:00
Christopher Allan Webber
c2059c4a74 Making alembic happen with python 3 only... for now.
We want to make sure it works nicely first.
2014-09-22 14:09:59 -05:00
Christopher Allan Webber
a6252cbf21 Merge branch 'merge-python3-port'
Conflicts:
	setup.py
2014-09-22 13:58:13 -05:00
ayleph
f0e795df82 Modify deleteuser to fail gracefully
bin/gmg deleteuser will produce a traceback error if you attempt to delete a
user who does not exist. This commit provides a fix to allow deletuser to fail
gracefully.

This commit addresses https://issues.mediagoblin.org/ticket/969
2014-09-16 15:29:09 -07:00
Christopher Allan Webber
f6bad0eb26 Merge branch 'master' into merge-python3-port
Has some issues, will iteratively fix!

Conflicts:
	mediagoblin/gmg_commands/__init__.py
	mediagoblin/gmg_commands/deletemedia.py
	mediagoblin/gmg_commands/users.py
	mediagoblin/oauth/views.py
	mediagoblin/plugins/api/views.py
	mediagoblin/tests/test_api.py
	mediagoblin/tests/test_edit.py
	mediagoblin/tests/test_oauth1.py
	mediagoblin/tests/test_util.py
	mediagoblin/tools/mail.py
	mediagoblin/webfinger/views.py
	setup.py
2014-09-16 14:01:43 -05:00
Berker Peksag
39a9035487 Implement ServeCommand.{loadserver, loadapp}.
This is partly port from PasteScript.
2014-08-15 23:07:35 +03:00
Berker Peksag
051c728c6e Add an initial "gmg serve" implementation.
The CLI is similar to "paster serve".
2014-08-15 23:02:22 +03:00
Berker Peksag
2064ad9450 Move the AlembicMigrationManager to top of the module.
Also, add a simple docstring.
2014-08-15 15:40:35 +03:00
Berker Peksag
65f20ca435 Add initial Alembic migrations. 2014-08-13 19:30:23 +03:00
Berker Peksag
7df0793441 Fix dict.keys() in Python 3. 2014-08-13 19:27:49 +03:00
Berker Peksag
4930c2adbd Fix a comment. 2014-08-13 19:27:23 +03:00
Stéphane Péchard
a3c480248f Add collection option to 'addmedia' cli uploading 2014-07-13 19:01:09 +02:00
tilly-Q
4285fc67b3 This was a very simple update. The gmg command adduser was generating an
unncessary error because we were searching for a non-unicode string value in a
Unicode column of the core__users table.
2014-07-10 10:28:34 -05:00
Berker Peksag
f9d93c0e9a Fix print statements. 2014-06-29 04:13:23 +03:00
Natalie Foust-Pilcher
446cece470 Used the codecs library to read the csv file in batchaddmedia as unicode. 2014-06-21 15:26:23 -04:00
Berker Peksag
9da03b739f Convert media_ids to int safely.
With this commit, "gmg deletemedia spam,12" will not raise
ValueError anymore.
2014-06-13 10:30:46 -05:00
Berker Peksag
25b1296ded Properly exit when "gmg deletemedia" succeed.
Also, fixed a typo: "to will be" -> "will be"
2014-06-13 10:30:46 -05:00
Loïc Le Ninan
8c7ba963af #303 : enhancement : add a command to delete users 2014-06-11 16:42:26 -05:00
Berker Peksag
d9aced73f1 The file() builtin has been removed in Python 3. Use open() instead. 2014-06-07 13:51:42 +03:00