From c2ddd85e4ac6c50289711fb5673dd716329a569b Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 11 Jul 2011 21:09:36 -0500 Subject: [PATCH] Removing old style migrations... not in use anymore --- mediagoblin/db/migrations.py | 58 +----------------------------------- mediagoblin/db/models.py | 8 ++--- 2 files changed, 3 insertions(+), 63 deletions(-) diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index 4cafb1a3..683a57f3 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -14,67 +14,11 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.util import cleaned_markdown_conversion -# from mediagoblin.db.util import RegisterMigration +from mediagoblin.db.util import RegisterMigration -from mongokit import DocumentMigration - - -# This is where the first new-style migration will be written! -# # Please see mediagoblin/tests/test_migrations.py for some examples of # basic migrations. # @RegisterMigration(1) # def do_something(database): # pass - - -class MediaEntryMigration(DocumentMigration): - def allmigration01_uploader_to_reference(self): - """ - Old MediaEntry['uploader'] accidentally embedded the User instead - of referencing it. Fix that! - """ - # uploader is an associative array - self.target = {'uploader': {'$type': 3}} - if not self.status: - for doc in self.collection.find(self.target): - self.update = { - '$set': { - 'uploader': doc['uploader']['_id']}} - self.collection.update( - self.target, self.update, multi=True, safe=True) - - def allmigration02_add_description_html(self): - """ - Now that we can have rich descriptions via Markdown, we should - update all existing entries to record the rich description versions. - """ - self.target = {'description_html': {'$exists': False}, - 'description': {'$exists': True}} - - if not self.status: - for doc in self.collection.find(self.target): - self.update = { - '$set': { - 'description_html': cleaned_markdown_conversion( - doc['description'])}} - -class UserMigration(DocumentMigration): - def allmigration01_add_bio_and_url_profile(self): - """ - User can elaborate profile with home page and biography - """ - self.target = {'url': {'$exists': False}, - 'bio': {'$exists': False}} - if not self.status: - for doc in self.collection.find(self.target): - self.update = { - '$set': {'url': '', - 'bio': ''}} - self.collection.update( - self.target, self.update, multi=True, safe=True) - - -MIGRATE_CLASSES = ['MediaEntry', 'User'] diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 279cb9f2..918dee0e 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -16,12 +16,11 @@ import datetime, uuid -from mongokit import Document, Set +from mongokit import Document from mediagoblin import util from mediagoblin.auth import lib as auth_lib from mediagoblin import mg_globals -from mediagoblin.db import migrations from mediagoblin.db.util import ASCENDING, DESCENDING, ObjectId ################### @@ -59,8 +58,6 @@ class User(Document): 'verification_key': lambda: unicode(uuid.uuid4()), 'is_admin': False} - migration_handler = migrations.UserMigration - def check_login(self, password): """ See if a user can login with this password @@ -106,8 +103,6 @@ class MediaEntry(Document): 'created': datetime.datetime.utcnow, 'state': u'unprocessed'} - migration_handler = migrations.MediaEntryMigration - def get_comments(self): return self.db.MediaComment.find({ 'media_entry': self['_id']}).sort('created', DESCENDING) @@ -196,6 +191,7 @@ class MediaComment(Document): def author(self): return self.db.User.find_one({'_id': self['author']}) + REGISTER_MODELS = [ MediaEntry, User, -- 2.25.1