Style: Prepend "operation_" to data migrations
Prepend "operation_" to the data migration functions for clear purpose. Add keyword arguments to the RunPython migration opration. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def move_from_content_type_user_to_foreign_key_field_user(apps, schema_editor):
|
||||
def operation_move_from_content_type_user_to_foreign_key_field_user(apps, schema_editor):
|
||||
# The model references the use who checked out the document using a
|
||||
# generic.GenericForeignKey. This migrations changes that to a simpler
|
||||
# ForeignKey to the User model
|
||||
@@ -24,6 +24,6 @@ class Migration(migrations.Migration):
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
move_from_content_type_user_to_foreign_key_field_user
|
||||
code=operation_move_from_content_type_user_to_foreign_key_field_user
|
||||
),
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
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 :)
|
||||
@@ -43,5 +43,5 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migrate_old_comments),
|
||||
migrations.RunPython(code=operation_migrate_old_comments),
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.db import migrations
|
||||
from django.template.defaultfilters import slugify
|
||||
|
||||
|
||||
def assign_slugs(apps, schema_editor):
|
||||
def operation_assign_slugs(apps, schema_editor):
|
||||
Index = apps.get_model('document_indexing', 'Index')
|
||||
|
||||
for index in Index.objects.using(schema_editor.connection.alias).all():
|
||||
@@ -19,5 +19,5 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(assign_slugs),
|
||||
migrations.RunPython(code=operation_assign_slugs),
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@ import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def create_parsing_setting_for_existing_document_types(apps, schema_editor):
|
||||
def operation_create_parsing_setting_for_existing_document_types(apps, schema_editor):
|
||||
DocumentType = apps.get_model('documents', 'DocumentType')
|
||||
DocumentTypeSettings = apps.get_model(
|
||||
'document_parsing', 'DocumentTypeSettings'
|
||||
@@ -19,7 +19,7 @@ def create_parsing_setting_for_existing_document_types(apps, schema_editor):
|
||||
pass
|
||||
|
||||
|
||||
def delete_parsing_setting_for_existing_document_types(apps, schema_editor):
|
||||
def operation_delete_parsing_setting_for_existing_document_types(apps, schema_editor):
|
||||
DocumentType = apps.get_model('documents', 'DocumentType')
|
||||
DocumentTypeSettings = apps.get_model(
|
||||
'document_parsing', 'DocumentTypeSettings'
|
||||
@@ -72,7 +72,7 @@ class Migration(migrations.Migration):
|
||||
},
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=create_parsing_setting_for_existing_document_types,
|
||||
reverse_code=delete_parsing_setting_for_existing_document_types,
|
||||
code=operation_create_parsing_setting_for_existing_document_types,
|
||||
reverse_code=operation_delete_parsing_setting_for_existing_document_types,
|
||||
)
|
||||
]
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.utils.text import slugify
|
||||
from mayan.apps.common.validators import validate_internal_name
|
||||
|
||||
|
||||
def generate_internal_name(apps, schema_editor):
|
||||
def operation_generate_internal_name(apps, schema_editor):
|
||||
Workflow = apps.get_model('document_states', 'Workflow')
|
||||
internal_names = []
|
||||
|
||||
@@ -48,7 +48,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
# Generate the slugs based on the labels
|
||||
migrations.RunPython(
|
||||
generate_internal_name, reverse_code=migrations.RunPython.noop
|
||||
code=operation_generate_internal_name, reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
|
||||
# Make the internal name field unique
|
||||
|
||||
@@ -7,7 +7,7 @@ import re
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def update_event_types_names(apps, schema_editor):
|
||||
def operation_update_event_types_names(apps, schema_editor):
|
||||
Action = apps.get_model('actstream', 'Action')
|
||||
StoredEventType = apps.get_model('events', 'StoredEventType')
|
||||
|
||||
@@ -35,7 +35,7 @@ def update_event_types_names(apps, schema_editor):
|
||||
action.save()
|
||||
|
||||
|
||||
def revert_event_types_names(apps, schema_editor):
|
||||
def operation_revert_event_types_names(apps, schema_editor):
|
||||
Action = apps.get_model('actstream', 'Action')
|
||||
StoredEventType = apps.get_model('events', 'StoredEventType')
|
||||
|
||||
@@ -80,7 +80,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
code=update_event_types_names,
|
||||
reverse_code=revert_event_types_names
|
||||
code=operation_update_event_types_names,
|
||||
reverse_code=operation_revert_event_types_names
|
||||
),
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def move_content_from_documents_to_ocr_app(apps, schema_editor):
|
||||
def operation_move_content_from_documents_to_ocr_app(apps, schema_editor):
|
||||
DocumentPage = apps.get_model('documents', 'DocumentPage')
|
||||
DocumentPageContent = apps.get_model('ocr', 'DocumentPageContent')
|
||||
|
||||
@@ -22,5 +22,5 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(move_content_from_documents_to_ocr_app),
|
||||
migrations.RunPython(code=operation_move_content_from_documents_to_ocr_app),
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
def create_ocr_setting_for_existing_document_types(apps, schema_editor):
|
||||
def operation_create_ocr_setting_for_existing_document_types(apps, schema_editor):
|
||||
DocumentType = apps.get_model('documents', 'DocumentType')
|
||||
DocumentTypeSettings = apps.get_model('ocr', 'DocumentTypeSettings')
|
||||
|
||||
@@ -55,5 +55,5 @@ class Migration(migrations.Migration):
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.RunPython(create_ocr_setting_for_existing_document_types),
|
||||
migrations.RunPython(code=operation_create_ocr_setting_for_existing_document_types),
|
||||
]
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def make_labels_unique(apps, schema_editor):
|
||||
def operation_make_labels_unique(apps, schema_editor):
|
||||
Source = apps.get_model('sources', 'Source')
|
||||
|
||||
for source in Source.objects.using(schema_editor.connection.alias).all():
|
||||
@@ -18,7 +18,7 @@ def make_labels_unique(apps, schema_editor):
|
||||
source.save()
|
||||
|
||||
|
||||
def make_labels_unique_reverse(apps, schema_editor):
|
||||
def operation_make_labels_unique_reverse(apps, schema_editor):
|
||||
Source = apps.get_model('sources', 'Source')
|
||||
|
||||
for source in Source.objects.using(schema_editor.connection.alias).all():
|
||||
@@ -35,7 +35,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
make_labels_unique, reverse_code=make_labels_unique_reverse
|
||||
code=operation_make_labels_unique, reverse_code=operation_make_labels_unique_reverse
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='source',
|
||||
|
||||
@@ -31,7 +31,7 @@ RGB_VALUES = {
|
||||
}
|
||||
|
||||
|
||||
def convert_color_names_to_rgb(apps, schema_editor):
|
||||
def operation_convert_color_names_to_rgb(apps, schema_editor):
|
||||
Tag = apps.get_model('tags', 'Tag')
|
||||
|
||||
for tag in Tag.objects.using(schema_editor.connection.alias).all():
|
||||
@@ -52,5 +52,5 @@ class Migration(migrations.Migration):
|
||||
field=colorful.fields.RGBColorField(default='#FFFFFF'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.RunPython(convert_color_names_to_rgb),
|
||||
migrations.RunPython(code=operation_convert_color_names_to_rgb),
|
||||
]
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
def add_user_options_to_existing_users(apps, schema_editor):
|
||||
def operation_add_user_options_to_existing_users(apps, schema_editor):
|
||||
User = apps.get_model(settings.AUTH_USER_MODEL)
|
||||
UserOptions = apps.get_model(
|
||||
app_label='user_management', model_name='UserOptions'
|
||||
@@ -19,7 +19,7 @@ def add_user_options_to_existing_users(apps, schema_editor):
|
||||
).create(user=user)
|
||||
|
||||
|
||||
def remove_user_options_from_existing_users(apps, schema_editor):
|
||||
def operation_remove_user_options_from_existing_users(apps, schema_editor):
|
||||
User = apps.get_model(settings.AUTH_USER_MODEL)
|
||||
UserOptions = apps.get_model(
|
||||
app_label='user_management', model_name='UserOptions'
|
||||
@@ -53,7 +53,7 @@ class Migration(migrations.Migration):
|
||||
},
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=add_user_options_to_existing_users,
|
||||
reverse_code=remove_user_options_from_existing_users
|
||||
code=operation_add_user_options_to_existing_users,
|
||||
reverse_code=operation_remove_user_options_from_existing_users
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user