Removing old style migrations... not in use anymore
This commit is contained in:
parent
0c915735d5
commit
c2ddd85e4a
@ -14,67 +14,11 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
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
|
# Please see mediagoblin/tests/test_migrations.py for some examples of
|
||||||
# basic migrations.
|
# basic migrations.
|
||||||
|
|
||||||
# @RegisterMigration(1)
|
# @RegisterMigration(1)
|
||||||
# def do_something(database):
|
# def do_something(database):
|
||||||
# pass
|
# 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']
|
|
||||||
|
@ -16,12 +16,11 @@
|
|||||||
|
|
||||||
import datetime, uuid
|
import datetime, uuid
|
||||||
|
|
||||||
from mongokit import Document, Set
|
from mongokit import Document
|
||||||
|
|
||||||
from mediagoblin import util
|
from mediagoblin import util
|
||||||
from mediagoblin.auth import lib as auth_lib
|
from mediagoblin.auth import lib as auth_lib
|
||||||
from mediagoblin import mg_globals
|
from mediagoblin import mg_globals
|
||||||
from mediagoblin.db import migrations
|
|
||||||
from mediagoblin.db.util import ASCENDING, DESCENDING, ObjectId
|
from mediagoblin.db.util import ASCENDING, DESCENDING, ObjectId
|
||||||
|
|
||||||
###################
|
###################
|
||||||
@ -59,8 +58,6 @@ class User(Document):
|
|||||||
'verification_key': lambda: unicode(uuid.uuid4()),
|
'verification_key': lambda: unicode(uuid.uuid4()),
|
||||||
'is_admin': False}
|
'is_admin': False}
|
||||||
|
|
||||||
migration_handler = migrations.UserMigration
|
|
||||||
|
|
||||||
def check_login(self, password):
|
def check_login(self, password):
|
||||||
"""
|
"""
|
||||||
See if a user can login with this password
|
See if a user can login with this password
|
||||||
@ -106,8 +103,6 @@ class MediaEntry(Document):
|
|||||||
'created': datetime.datetime.utcnow,
|
'created': datetime.datetime.utcnow,
|
||||||
'state': u'unprocessed'}
|
'state': u'unprocessed'}
|
||||||
|
|
||||||
migration_handler = migrations.MediaEntryMigration
|
|
||||||
|
|
||||||
def get_comments(self):
|
def get_comments(self):
|
||||||
return self.db.MediaComment.find({
|
return self.db.MediaComment.find({
|
||||||
'media_entry': self['_id']}).sort('created', DESCENDING)
|
'media_entry': self['_id']}).sort('created', DESCENDING)
|
||||||
@ -196,6 +191,7 @@ class MediaComment(Document):
|
|||||||
def author(self):
|
def author(self):
|
||||||
return self.db.User.find_one({'_id': self['author']})
|
return self.db.User.find_one({'_id': self['author']})
|
||||||
|
|
||||||
|
|
||||||
REGISTER_MODELS = [
|
REGISTER_MODELS = [
|
||||||
MediaEntry,
|
MediaEntry,
|
||||||
User,
|
User,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user