Code cleanups
PEP8 cleanups. Add keyword arguments. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def migrate_old_comments(apps, schema_editor):
|
||||
def operation_migrate_old_comments(apps, schema_editor):
|
||||
# https://code.djangoproject.com/ticket/24282
|
||||
# If someone has a better solution until Django 1.8, would appreciate
|
||||
# a pull-request :)
|
||||
@@ -17,13 +16,19 @@ def migrate_old_comments(apps, schema_editor):
|
||||
pass
|
||||
else:
|
||||
|
||||
Comment = apps.get_model('document_comments', 'Comment')
|
||||
Document = apps.get_model('documents', 'Document')
|
||||
Comment = apps.get_model(
|
||||
app_label='document_comments', model_name='Comment'
|
||||
)
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
User = apps.get_model(*settings.AUTH_USER_MODEL.split('.'))
|
||||
|
||||
for old_comment in OldComment.objects.using(schema_editor.connection.alias).all():
|
||||
comment = Comment(
|
||||
document=Document.objects.using(schema_editor.connection.alias).get(pk=old_comment.object_pk),
|
||||
document=Document.objects.using(
|
||||
schema_editor.connection.alias
|
||||
).get(pk=old_comment.object_pk),
|
||||
user=User(old_comment.user.pk),
|
||||
comment=old_comment.comment,
|
||||
submit_date=old_comment.submit_date,
|
||||
@@ -42,5 +47,5 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migrate_old_comments),
|
||||
migrations.RunPython(code=operation_migrate_old_comments),
|
||||
]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
Reference in New Issue
Block a user