diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-05-30 20:26:21 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 09:57:24 +0200 |
commit | 10b603af68689ea3b251006b7ec05855b9616811 (patch) | |
tree | 981ddce21bc6bad956c5b012baf9608fdfe909b1 /archaeological_warehouse | |
parent | bdfc5407eb4790c86e5ffe80d3ac0cc68fb5a9a2 (diff) | |
download | Ishtar-10b603af68689ea3b251006b7ec05855b9616811.tar.bz2 Ishtar-10b603af68689ea3b251006b7ec05855b9616811.zip |
Migrate images and sources to new document model (refs #4107)
Diffstat (limited to 'archaeological_warehouse')
3 files changed, 53 insertions, 3 deletions
diff --git a/archaeological_warehouse/migrations/0019_warehouse_documents.py b/archaeological_warehouse/migrations/0019_warehouse_documents.py new file mode 100644 index 000000000..08ee5cb34 --- /dev/null +++ b/archaeological_warehouse/migrations/0019_warehouse_documents.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-05-30 19:00 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0055_auto_20180530_1900'), + ('archaeological_warehouse', '0018_auto_20180528_1141'), + ] + + operations = [ + migrations.AddField( + model_name='warehouse', + name='documents', + field=models.ManyToManyField(blank=True, related_name='warehouses', to='ishtar_common.Document', verbose_name='Documents'), + ), + ] diff --git a/archaeological_warehouse/migrations/0020_migrate_source_and_image.py b/archaeological_warehouse/migrations/0020_migrate_source_and_image.py new file mode 100644 index 000000000..1db07eee4 --- /dev/null +++ b/archaeological_warehouse/migrations/0020_migrate_source_and_image.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-05-30 19:38 +from __future__ import unicode_literals + +from django.db import migrations + + +from ishtar_common.utils_migrations import migrate_images + + +def migrate_source_and_image(apps, schema_editor): + Warehouse = apps.get_model( + 'archaeological_warehouse', 'Warehouse') + WarehouseImage = apps.get_model( + 'archaeological_warehouse', 'WarehouseImage') + migrate_images(apps, Warehouse, WarehouseImage) + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_warehouse', '0019_warehouse_documents'), + ] + + operations = [ + migrations.RunPython(migrate_source_and_image) + ] diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 40de49d60..30c117fc2 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -27,11 +27,10 @@ from django.template.defaultfilters import slugify from django.utils.translation import ugettext_lazy as _ from ishtar_common.data_importer import post_importer_action -from ishtar_common.utils import cached_label_changed - -from ishtar_common.models import GeneralType, get_external_id, \ +from ishtar_common.models import Document, GeneralType, get_external_id, \ LightHistorizedItem, OwnPerms, Address, Person, post_save_cache, \ ImageModel, DashboardFormItem, IshtarImage, ThroughImage +from ishtar_common.utils import cached_label_changed class WarehouseType(GeneralType): @@ -63,6 +62,9 @@ class Warehouse(Address, DashboardFormItem, OwnPerms): 'WarehouseDivision', verbose_name=_("Divisions"), blank=True, through='WarehouseDivisionLink' ) + documents = models.ManyToManyField( + Document, related_name='warehouses', verbose_name=_(u"Documents"), + blank=True) images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"), through='WarehouseImage', blank=True) external_id = models.TextField(_(u"External ID"), blank=True, null=True) |