diff options
Diffstat (limited to 'archaeological_operations')
3 files changed, 117 insertions, 15 deletions
diff --git a/archaeological_operations/migrations/0030_auto_20180530_1900.py b/archaeological_operations/migrations/0030_auto_20180530_1900.py new file mode 100644 index 000000000..b755c293b --- /dev/null +++ b/archaeological_operations/migrations/0030_auto_20180530_1900.py @@ -0,0 +1,67 @@ +# -*- 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 +import django.db.models.deletion + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('ishtar_common', '0055_auto_20180530_1900'), +        ('archaeological_operations', '0029_auto_20180511_1232'), +    ] + +    operations = [ +        migrations.AddField( +            model_name='archaeologicalsite', +            name='documents', +            field=models.ManyToManyField(blank=True, related_name='sites', to='ishtar_common.Document', verbose_name='Documents'), +        ), +        migrations.AddField( +            model_name='operation', +            name='documents', +            field=models.ManyToManyField(blank=True, related_name='operations', to='ishtar_common.Document', verbose_name='Documents'), +        ), +        migrations.AddField( +            model_name='operationsource', +            name='associated_links', +            field=models.TextField(blank=True, null=True, verbose_name='Symbolic links'), +        ), +        migrations.AddField( +            model_name='operationsource', +            name='authors_raw', +            field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Authors (raw)'), +        ), +        migrations.AddField( +            model_name='operationsource', +            name='licenses', +            field=models.ManyToManyField(blank=True, to='ishtar_common.LicenseType', verbose_name='License'), +        ), +        migrations.AlterField( +            model_name='operationsource', +            name='external_id', +            field=models.TextField(blank=True, null=True, verbose_name='External ID'), +        ), +        migrations.AlterField( +            model_name='operationsource', +            name='internal_reference', +            field=models.TextField(blank=True, null=True, verbose_name='Internal ref.'), +        ), +        migrations.AlterField( +            model_name='operationsource', +            name='reference', +            field=models.TextField(blank=True, null=True, verbose_name='Ref.'), +        ), +        migrations.AlterField( +            model_name='operationsource', +            name='source_type', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.SourceType', verbose_name='Type'), +        ), +        migrations.AlterField( +            model_name='operationsource', +            name='title', +            field=models.TextField(blank=True, default=b'', verbose_name='Title'), +        ), +    ] diff --git a/archaeological_operations/migrations/0031_migrate_source_and_image.py b/archaeological_operations/migrations/0031_migrate_source_and_image.py new file mode 100644 index 000000000..172e86203 --- /dev/null +++ b/archaeological_operations/migrations/0031_migrate_source_and_image.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-05-30 19:01 +from __future__ import unicode_literals + +from django.db import migrations + +from ishtar_common.utils_migrations import migrate_images, migrate_sources + + +def migrate_source_and_image(apps, schema_editor): +    ArchaeologicalSite = apps.get_model( +        'archaeological_operations', 'ArchaeologicalSite') +    SiteImage = apps.get_model('archaeological_operations', 'SiteImage') +    migrate_images(apps, ArchaeologicalSite, SiteImage) + +    Operation = apps.get_model('archaeological_operations', 'Operation') +    OperationImage = apps.get_model('archaeological_operations', +                                    'OperationImage') +    OperationSource = apps.get_model('archaeological_operations', +                                     'OperationSource') +    migrate_images(apps, Operation, OperationImage) +    migrate_sources(apps, Operation, OperationSource, 'operation') + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('archaeological_operations', '0030_auto_20180530_1900'), +    ] + +    operations = [ +        migrations.RunPython(migrate_source_and_image) +    ] diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 44406fd89..de58e0da7 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -22,7 +22,6 @@ from itertools import groupby  from django.conf import settings  from django.contrib.gis.db import models -from django.core.cache import cache  from django.core.urlresolvers import reverse  from django.db import IntegrityError, transaction  from django.db.models import Q, Count, Sum, Max, Avg @@ -30,15 +29,15 @@ from django.db.models.signals import post_save, m2m_changed, post_delete  from django.forms import ValidationError  from django.utils.translation import ugettext_lazy as _, ugettext +from ishtar_common.models import BaseHistorizedItem, BaseSource, Dashboard, \ +    DashboardFormItem, Department, Document, DocumentTemplate, \ +    GeneralRecordRelations, GeneralRelationType, GeneralType, \ +    HistoricalRecords, IshtarImage, IshtarUser, LightHistorizedItem, \ +    OperationType, Organization, OwnPerms, Person, PersonType, \ +    post_delete_record_relation, post_save_cache, RelationItem, \ +    ShortMenuItem, SourceType, ThroughImage, Town, ValueGetter  from ishtar_common.utils import cached_label_changed, \ -    force_cached_label_changed, get_cache, mode - -from ishtar_common.models import GeneralType, BaseHistorizedItem, \ -    HistoricalRecords, LightHistorizedItem, OwnPerms, Department, Source,\ -    SourceType, Person, Organization, Town, Dashboard, IshtarUser, ValueGetter,\ -    DocumentTemplate, ShortMenuItem, DashboardFormItem, GeneralRelationType,\ -    GeneralRecordRelations, post_delete_record_relation, OperationType, \ -    post_save_cache, PersonType, IshtarImage, RelationItem, ThroughImage +    force_cached_label_changed, mode  class RemainType(GeneralType): @@ -129,6 +128,9 @@ class ArchaeologicalSite(BaseHistorizedItem):          _(u"Sinking date"), null=True, blank=True)      discovery_area = models.TextField(          _(u"Discovery area"), null=True, blank=True) +    documents = models.ManyToManyField( +        Document, related_name="sites", verbose_name=_(u"Documents"), +        blank=True)      images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),                                      through='SiteImage', blank=True) @@ -459,6 +461,9 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,      comment = models.TextField(_(u"Comment"), null=True, blank=True)      scientific_documentation_comment = models.TextField(          _(u"Comment about scientific documentation"), null=True, blank=True) +    documents = models.ManyToManyField( +        Document, related_name='operations', verbose_name=_(u"Documents"), +        blank=True)      images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),                                      blank=True, through='OperationImage')      cached_label = models.CharField(_(u"Cached name"), max_length=500, @@ -1039,11 +1044,11 @@ class OperationByDepartment(models.Model):          db_table = 'operation_department' -class OperationSource(Source): +class OperationSource(BaseSource):      SHOW_URL = 'show-operationsource'      MODIFY_URL = 'operation_source_modify'      TABLE_COLS = ['operation__code_patriarche', 'operation__year', -                  'operation__operation_code', 'code'] + Source.TABLE_COLS +                  'operation__operation_code', 'code'] + BaseSource.TABLE_COLS      # search parameters      BOOL_FIELDS = ['duplicate'] @@ -1063,14 +1068,11 @@ class OperationSource(Source):          'operation__operation_code': _(u"Operation code"),          'code': _(u"Document code")      } -    PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['operation'] - +    PARENT_SEARCH_VECTORS = BaseSource.PARENT_SEARCH_VECTORS + ['operation']      # fields      operation = models.ForeignKey(Operation, verbose_name=_(u"Operation"),                                    related_name="source") -    index = models.IntegerField(verbose_name=_(u"Index"), blank=True, -                                null=True)      class Meta:          verbose_name = _(u"Operation documentation")  | 
