aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db
Commit message (Collapse)AuthorAgeFilesLines
...
* | import db.sql.util -> db.utilSebastian Spaeth2013-01-171-1/+1
| | | | | | | | | | | | | | Merging an old branch, I reintroduced an import of db.sql.util rather than db.util. Fixing the glitch. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Implement User.delete() (#540)Sebastian Spaeth2013-01-171-1/+22
| | | | | | | | | | | | | | | | | | Set User.collections to her Collections using the backref feature. This way we can iterate a user's collections and delete them all. Delete all MediaEntries/Files/attachments/comments/collections etc before finally deleting the User object. This is the backend work for issue 302 (allow a user to delete ones own account)
* | Implement Collection.delete()Sebastian Spaeth2013-01-171-1/+10
| | | | | | | | | | | | Deleting a Collection should automatically delete all containing items. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Implement MediaEntry().delete() (#540)Sebastian Spaeth2013-01-171-3/+36
|/ | | | | | | | | | | | Deleting a MediaEntry instance will automatically delete all related comments and files/attachments. This moves implementation logic out of views.py and allows to make use of this functionality when e.g. deleting a User() account. Whenever a MediaEntry entry is deleted, this will also sql-delete the corresponding MediaFile entry. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Simplify check_media_slug_usedSebastian Spaeth2013-01-152-7/+5
| | | | | | | Remove the unused dummy_db argument and generally make the function readable. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Move db.sql.migration_tools to db.migration_tools.Elrond2013-01-082-1/+1
| | | | Follow the new trend.
* Add inspect_table.Elrond2013-01-082-7/+11
| | | | | | In our current scheme of migrations, we reflect the current sql schema into an SQLAlchemy schema. So let's have a tool function for this.
* Move all the migration tools into new migration_tools.pyElrond2013-01-083-250/+265
| | | | | | | | | Factor all the migration related stuff out into a new .db.sql.migration_tools. First we don't have to load this module for our normal server. Second it makes all the import dependencies a little more cleaner.
* Remove custom GMQuery classSebastian Spaeth2013-01-071-14/+1
| | | | | | | | | We provided a custom GMQuery class that offered a .sort() method for compatibility with the Mongo syntax. Now that we have settled for sqlalchemy which uses the order_by() method, we can safely remove this custom class and move a little closer to "pure" and native sqlalchemy usage. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Mv db.sql.base to db.baseSebastian Spaeth2013-01-076-21/+4
| | | | | | | | This concludes the db.sql.* -> db.* move. Our db abstraction layer is sqlalchemy, so there is no need to a separate db.sql.* hierarchy. All tests have been run for each of the commit series to make sure everything works at every step.
* Move mediagoblin.db.sql.extratypes to mediagoblin.db.extratypesSebastian Spaeth2013-01-073-2/+2
| | | | No other functional changes.
* Move db.sql.models* to db.models*Sebastian Spaeth2013-01-075-5/+5
|
* Move db.sql.util to db.utilSebastian Spaeth2013-01-073-331/+310
| | | | | | | | Now that sqlalchemy is providing the database abstractions, there is no need to hide everything in db.sql. sub-modules. It complicates the code and provides a futher layer of indirection. Move the db.sql.util.py to db.util.py and adapt the importers.
* Remove mediagoblin.db.sql.fake.DESCENDINGSebastian Spaeth2013-01-073-35/+1
| | | | | | | | This is the last remnant that requires us to keep db.sql.fake.py. Use ModelName.desc() or sqlalchemy.sql.expression.desc(column) to achieve descending sorts. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Remove ObjectId from the treeSebastian Spaeth2012-12-252-10/+1
| | | | | | | This was one of the last remaining Mongo holdouts and has been removed from the tree herewith. Good bye, ObjectId. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Remove InvalidIdSebastian Spaeth2012-12-252-10/+2
| | | | | | It was a NoOp in our Non-mongo world. So it is safe to remove. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Move db.sql.migrations to db.migrationsSebastian Spaeth2012-12-251-0/+0
|
* Move db.sql.open to db.openSebastian Spaeth2012-12-253-82/+63
| | | | | | Now that mongo has been ripped out and sqlalchemy is already providing the database abstraction, there is no need to hide everything in the sql module. Transition db.sql.open to db.open and adapt all direct importers.
* RIP out mongoSebastian Spaeth2012-12-2513-1400/+7
| | | | | | | | | Since sqlalchemy is providing our database abstraction and we have moved away from Mongo as the underlying database, it is now time to simplify things and rip out mongo. This provides the bulk of the changes, and can stand on its own. There are some followup tasks that can be done, such as removing now unneeded abstraction layers, e.g. db.sql.fake.py
* Mongo removal: Remove the validate=True arg to obj.save()Elrond2012-12-241-2/+1
| | | | | all callers were forced to use validate=True anyway. So remove this useless stuff.
* Remove Mongoism query.skip()Sebastian Spaeth2012-12-211-3/+0
| | | | | | | | | | sqlalchemy supports slice() or [n:m] just fine. Right now, it seems we cannot distinguish beween "empty" results and out-of bound slices. It would be nice if we could distinguish these somehow. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Remove SimpleFieldAliasSebastian Spaeth2012-12-211-12/+0
| | | | | | | It was only used for the model._id -> model.id conversion and is not needed anymore. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Move DBModel._id -> DBModel.idSebastian Spaeth2012-12-213-29/+6
| | | | | | | | | | | | | | | | | | | | | | | We were refering to model._id in most of the code base as this is what Mongo uses. However, each use of _id required a) fixup of queries: e.g. what we did in our find() and find_one() functions moving all '_id' to 'id'. It also required using AliasFields to make the ._id attribute available. This all means lots of superfluous fixing and transitioning in a SQL world. It will also not work in the long run. Much newer code already refers to the objects by model.id (e.g. in the oauth plugin), which will break with Mongo. So let's be honest, rip out the _id mongoism and live with .id as the one canonical way to address objects. This commit modifies all users and providers of model._id to use model.id instead. This patch works with or without Mongo removed first, but will break Mongo usage (even more than before) I have not bothered to fixup db.mongo.* and db.sql.convert (which converts from Mongo to SQL) Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Remove print statments from this migration.Christopher Allan Webber2012-12-101-6/+5
| | | | | | | The reason for wanting to give extra information to the user (this is a very special case migration) is good, but we don't have a nice "official" way to capture and present that information during tests, so removing this.
* Fix typo, disable debugging.Elrond2012-12-101-3/+2
|
* UniqueConstraing migration: Adding the explaining comments.Elrond2012-12-101-0/+23
| | | | Add a lengthy comment explaining all the variants.
* Fixing our broken CollectionItem unique constraint.Elrond2012-12-101-4/+42
| | | | | This one seems to work nicely in all relevant situations. See comments inside the source.
* Ensure query_dict is a dict after the contents have been modified.Nathan Yergler2012-12-101-2/+8
| | | | | | _fix_query_dict modifies its argument in place. Ensure that the argument passed in has a local name and will be passed into the subsequent filter_by call.
* Eeek! Set the migration number to the current migration number being run!Christopher Allan Webber2012-12-091-1/+1
|
* Elrond's suggestion: have set_current_migration execute after each migration ↵Christopher Allan Webber2012-12-091-1/+1
| | | | run.
* make media_manager a property of MediaEntry in mixin.pySebastian Spaeth2012-12-041-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | In all cases where get_media_manager(_media_type_as_string) was called in our code base we ultimately passed in a "MediaEntry().media_type" to get the matching MEDIA_MANAGER. It so makes sense to make this a function of the MediaEntry rather than a global function in mediagoblin.media_types and passing around media_entry.media_type as arguments all the time. It saves a few import statements and arguments. I also made it so the Media_manager property is cached for subsequent calls, although I am not too sure that this is needed (there are other cases for which this would make more sense) Also add a get_media_manager test to the media submission tests. It submits an image and checks that both media.media_type and media.media_manager return the right thing. Not sure if these tests could not be merged with an existing submission test, but it can't hurt to have things explicit. TODO: Right now we iterate through all existing media_managers to find the right one based on the string of its module name. This should be made a simple dict lookup to avoid all the extra work. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Implement licenses.get_license_by_urlSebastian Spaeth2012-11-301-1/+1
| | | | | | | | | Rather than exploding in the user's face (for example if we custom-configure licenses in our MG instance, and there are still media with now "unknown" licenses in the db), simply return a License object as a fallback, where all attributes are set to the URL we were handed. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Use mediagoblin import machinerySebastian Spaeth2012-11-301-4/+5
| | | | | | | | | | | Rather than manually __importing__ the MEDIA_MANAGER, we should have been using tools.common.import_component in the first place. But even better to use the existing get_media_manager() function that exists for exactly our purpose. Also improve documentation of what happens in case of failure. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Remove importlib (python2.7'ism)Sebastian Spaeth2012-11-301-3/+1
| | | | | | | | importlib is cool, but only included in python2.7 which is beyond our minimum python version that we support. So simply use plain old __import__. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Merge some small bits by spaetz. Needed later.Elrond2012-11-282-6/+8
|\ | | | | | | | | | | * commit '9437ea4742': Add commit argument to clean_orphan_tags Add "commit" argument to Base model delete()
| * Add commit argument to clean_orphan_tagsSebastian Spaeth2012-11-281-4/+4
| | | | | | | | So we can prevent the session from being committed if we don't want it.
| * Add "commit" argument to Base model delete()Elrond2012-11-281-2/+4
| | | | | | | | | | | | | | | | | | In case we want to bundle db actions into a single transaction, we can now use delete(commit=False) to prevent the transaction from being committed immediately. This is useful when e.g. deleting a User() and thousands of his MediaEntries in a single commit. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Merge remote-tracking branch 'refs/remotes/elrond/sql/migrate_new_tables'Christopher Allan Webber2012-11-261-33/+45
|\ \ | |/ |/|
| * SQL Migrations: Rewrite table creation completely.Elrond2012-11-241-33/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | We have migrations creating new tables. Those currently use "raw" table definitions. This easily gives errors (we already had this problem). So instead rewrite those to use declarative tables and use those to create new tables. Just copy the new table over to the migration, strip it down to the bare minimum, rename to _v0, base it on declarative_base() and be done! Do this for the current migrations.
* | Stop unicode conversion warning during dbupdate.Elrond2012-11-241-1/+1
|/ | | | Just force the passed in name to MigrationManager() to unicode.
* Simplify/Robustify the thumbnail URL usage in templatesSebastian Spaeth2012-11-151-0/+19
| | | | | | | | | | | | | | | | | | | | | | So far templates required a very complex blurb to simply insert a thumbnail URL, exposing much of the internal logic to the template designer. In addition, we would fail with an error if for some reason the media_files['thumb'] entry was never populated. This adds the MediaEntry.thumb_url property that template designers can simply use. It will do the right thing, either fetching the proper thumbnail or hand back a generic icon specified in a media's MEDIA_MANAGER as "default_thumb". Add an image default fallback icon (stolen from Tangos, which are Public Domain since version 0.8.90 as I understand) since the one we referred to was not existing. Perhaps, a "broken image" icon would be better, but I'll leave that to our capable designers. All templates have been modified to make use of the new thumb_url function. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Added cascade all, delete-orphan to ProcessingMetaDataJoar Wandborg2012-09-271-5/+7
|
* HTTP callback fixesJoar Wandborg2012-09-261-1/+9
| | | | | | | | | | | - Added HTTPError catching around the callback request, to not mark the entry as failed, just log the exception. - Fixed bug where I forgot to actually fetch the entry before passing it to json_processing_callback. - Changed __main__ migration #6 to create the ProcessingMetaData table as it is currently, to prevent possible breakage if a siteadmin is lagging behind with his db migrations and more than one migration wants to fix stuff with the ProcessingMetaData table.
* Added support for http callbacks on processingJoar Wandborg2012-09-262-2/+24
| | | | | Sends an HTTP POST request back to an URL given on submission to the API submit view.
* Added client registration caps to OAuth pluginJoar Wandborg2012-09-212-7/+13
| | | | | | | | | | | | | | | | | | | THE MIGRATIONS SUPPLIED WITH THIS COMMIT WILL DROP AND RE-CREATE YOUR oauth__tokens AND oauth__codes TABLES. ALL YOUR OAUTH CODES AND TOKENS WILL BE LOST. - Fixed pylint issues in db/sql/migrations. - Added __repr__ to the User model. - Added _disable_cors option to json_response. - Added crude error handling to the api.tools.api_auth decorator - Updated the OAuth README. - Added client registration, client overview, connection overview, client authorization views and templates. - Added error handling to the OAuthAuth Auth object. - Added AuthorizationForm, ClientRegistrationForm in oauth/forms. - Added migrations for OAuth, added client registration migration. - Added OAuthClient, OAuthUserClient models. - Added oauth/tools with require_client_auth decorator method.
* Style fixesJoar Wandborg2012-09-181-0/+1
|
* Fixed collection sidebar for media_home to user collection.url_for_self ↵Aaron Williamson2012-09-181-1/+1
| | | | instead of incorrectly getting the session user
* Added default for 'collected' column to migrationAaron Williamson2012-09-181-1/+1
|
* Fixed migrations for Collection and CollectionItem tablesAaron Williamson2012-09-181-2/+5
|
* Added migrations for Collection and CollectionItem tablesAaron Williamson2012-09-181-1/+30
|