summaryrefslogtreecommitdiff
path: root/ishtar_common/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/migrations')
-rw-r--r--ishtar_common/migrations/0093_auto_20190429_0950.py50
-rw-r--r--ishtar_common/migrations/0094_auto_20190429_1041.py39
2 files changed, 89 insertions, 0 deletions
diff --git a/ishtar_common/migrations/0093_auto_20190429_0950.py b/ishtar_common/migrations/0093_auto_20190429_0950.py
new file mode 100644
index 000000000..d2bc6a395
--- /dev/null
+++ b/ishtar_common/migrations/0093_auto_20190429_0950.py
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.18 on 2019-04-29 09:50
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+CLASS_NAMES = {
+ 'archaeological_operations.models.AdministrativeAct': "Acte administratif"
+}
+
+
+def migrate_to_model_fk(apps, schema_editor):
+ ImporterModel = apps.get_model('ishtar_common', 'ImporterModel')
+ DocumentTemplate = apps.get_model('ishtar_common', 'DocumentTemplate')
+ importer_models = {}
+ for doc in DocumentTemplate.objects.all():
+ if doc.associated_object_name not in importer_models:
+ if doc.associated_object_name in CLASS_NAMES:
+ name = CLASS_NAMES[doc.associated_object_name]
+ else:
+ name = "-"
+ importer_models[doc.associated_object_name], __ = \
+ ImporterModel.objects.get_or_create(
+ klass=doc.associated_object_name,
+ defaults={"name": name}
+ )
+ doc.associated_model = importer_models[doc.associated_object_name]
+ doc.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0092_ishtarsiteprofile_display_srs'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='importermodel',
+ options={'ordering': ('name',), 'verbose_name': 'Model', 'verbose_name_plural': 'Models'},
+ ),
+ migrations.AddField(
+ model_name='documenttemplate',
+ name='associated_model',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImporterModel'),
+ ),
+ migrations.RunPython(migrate_to_model_fk),
+ ]
diff --git a/ishtar_common/migrations/0094_auto_20190429_1041.py b/ishtar_common/migrations/0094_auto_20190429_1041.py
new file mode 100644
index 000000000..6b068b2dc
--- /dev/null
+++ b/ishtar_common/migrations/0094_auto_20190429_1041.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.18 on 2019-04-29 10:41
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0093_auto_20190429_0950'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='documenttemplate',
+ options={'ordering': ['associated_model', 'name'], 'verbose_name': 'Patron de document', 'verbose_name_plural': 'Patrons de document'},
+ ),
+ migrations.RemoveField(
+ model_name='documenttemplate',
+ name='associated_object_name',
+ ),
+ migrations.AddField(
+ model_name='documenttemplate',
+ name='for_labels',
+ field=models.BooleanField(default=False, verbose_name='Used for labels'),
+ ),
+ migrations.AddField(
+ model_name='documenttemplate',
+ name='label_per_page',
+ field=models.IntegerField(blank=True, help_text='Only relevant for label template', null=True, verbose_name='Number of label per page'),
+ ),
+ migrations.AlterField(
+ model_name='documenttemplate',
+ name='associated_model',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImporterModel'),
+ ),
+ ]