Initialize document type file metadata settings
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.20 on 2019-04-24 08:42
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
def operation_initialize_file_metadata_settings(apps, schema_editor):
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
DocumentTypeSettings = apps.get_model(
|
||||
app_label='file_metadata', model_name='DocumentTypeSettings'
|
||||
)
|
||||
|
||||
for document_type in DocumentType.objects.using(schema_editor.connection.alias).all():
|
||||
DocumentTypeSettings.objects.using(
|
||||
schema_editor.connection.alias
|
||||
).create(document_type=document_type)
|
||||
|
||||
|
||||
def operation_initialize_file_metadata_settings_reverse(apps, schema_editor):
|
||||
DocumentTypeSettings = apps.get_model(
|
||||
app_label='file_metadata', model_name='DocumentTypeSettings'
|
||||
)
|
||||
DocumentTypeSettings.objects.using(schema_editor.connection.alias).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
@@ -75,4 +94,8 @@ class Migration(migrations.Migration):
|
||||
name='documentversiondriverentry',
|
||||
unique_together=set([('driver', 'document_version')]),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=operation_initialize_file_metadata_settings,
|
||||
reverse_code=operation_initialize_file_metadata_settings_reverse
|
||||
)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user