summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
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
commit10b603af68689ea3b251006b7ec05855b9616811 (patch)
tree981ddce21bc6bad956c5b012baf9608fdfe909b1 /archaeological_context_records
parentbdfc5407eb4790c86e5ffe80d3ac0cc68fb5a9a2 (diff)
downloadIshtar-10b603af68689ea3b251006b7ec05855b9616811.tar.bz2
Ishtar-10b603af68689ea3b251006b7ec05855b9616811.zip
Migrate images and sources to new document model (refs #4107)
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/migrations/0024_auto_20180530_1900.py67
-rw-r--r--archaeological_context_records/migrations/0025_migrate_source_and_image.py29
-rw-r--r--archaeological_context_records/models.py20
3 files changed, 108 insertions, 8 deletions
diff --git a/archaeological_context_records/migrations/0024_auto_20180530_1900.py b/archaeological_context_records/migrations/0024_auto_20180530_1900.py
new file mode 100644
index 000000000..5dac817ff
--- /dev/null
+++ b/archaeological_context_records/migrations/0024_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_context_records', '0023_auto_20180511_1232'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='contextrecord',
+ name='documents',
+ field=models.ManyToManyField(blank=True, related_name='context_records', to='ishtar_common.Document', verbose_name='Documents'),
+ ),
+ migrations.AddField(
+ model_name='contextrecordsource',
+ name='associated_links',
+ field=models.TextField(blank=True, null=True, verbose_name='Symbolic links'),
+ ),
+ migrations.AddField(
+ model_name='contextrecordsource',
+ name='authors_raw',
+ field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Authors (raw)'),
+ ),
+ migrations.AddField(
+ model_name='contextrecordsource',
+ name='index',
+ field=models.IntegerField(blank=True, null=True, verbose_name='Index'),
+ ),
+ migrations.AddField(
+ model_name='contextrecordsource',
+ name='licenses',
+ field=models.ManyToManyField(blank=True, to='ishtar_common.LicenseType', verbose_name='License'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecordsource',
+ name='external_id',
+ field=models.TextField(blank=True, null=True, verbose_name='External ID'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecordsource',
+ name='internal_reference',
+ field=models.TextField(blank=True, null=True, verbose_name='Internal ref.'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecordsource',
+ name='reference',
+ field=models.TextField(blank=True, null=True, verbose_name='Ref.'),
+ ),
+ migrations.AlterField(
+ model_name='contextrecordsource',
+ 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='contextrecordsource',
+ name='title',
+ field=models.TextField(blank=True, default=b'', verbose_name='Title'),
+ ),
+ ]
diff --git a/archaeological_context_records/migrations/0025_migrate_source_and_image.py b/archaeological_context_records/migrations/0025_migrate_source_and_image.py
new file mode 100644
index 000000000..c190faac2
--- /dev/null
+++ b/archaeological_context_records/migrations/0025_migrate_source_and_image.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2018-05-30 19:22
+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):
+ ContextRecord = apps.get_model(
+ 'archaeological_context_records', 'ContextRecord')
+ ContextRecordImage = apps.get_model(
+ 'archaeological_context_records', 'ContextRecordImage')
+ ContextRecordSource = apps.get_model(
+ 'archaeological_context_records', 'ContextRecordSource')
+ migrate_images(apps, ContextRecord, ContextRecordImage)
+ migrate_sources(apps, ContextRecord, ContextRecordSource, 'context_record')
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0024_auto_20180530_1900'),
+ ]
+
+ operations = [
+ migrations.RunPython(migrate_source_and_image)
+ ]
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index da488f773..b12a31516 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -30,11 +30,11 @@ from django.utils.text import slugify
from ishtar_common.utils import cached_label_changed
-from ishtar_common.models import GeneralType, BaseHistorizedItem, \
- HistoricalRecords, OwnPerms, ShortMenuItem, Source, GeneralRelationType,\
- GeneralRecordRelations, post_delete_record_relation, get_image_path, \
- post_save_cache, ValueGetter, BulkUpdatedItem, IshtarImage, RelationItem, \
- Town, ThroughImage
+from ishtar_common.models import BaseSource, Document, GeneralType, \
+ BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \
+ GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\
+ get_image_path, post_save_cache, ValueGetter, BulkUpdatedItem, \
+ IshtarImage, RelationItem, ThroughImage, Town
from archaeological_operations.models import Operation, Period, Parcel, \
ArchaeologicalSite
@@ -326,6 +326,9 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
point_2d = models.PointField(_(u"Point (2D)"), blank=True, null=True)
point = models.PointField(_(u"Point (3D)"), blank=True, null=True, dim=3)
polygon = models.PolygonField(_(u"Polygon"), blank=True, null=True)
+ documents = models.ManyToManyField(
+ Document, related_name='context_records', verbose_name=_(u"Documents"),
+ blank=True)
images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),
blank=True, through='ContextRecordImage')
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
@@ -678,11 +681,11 @@ class RecordRelationView(models.Model):
return u"{} \"{}\"".format(self.relation_type, self.right_record)
-class ContextRecordSource(Source):
+class ContextRecordSource(BaseSource):
SHOW_URL = 'show-contextrecordsource'
MODIFY_URL = 'record_source_modify'
TABLE_COLS = ['context_record__operation__cached_label', 'context_record']\
- + Source.TABLE_COLS
+ + BaseSource.TABLE_COLS
COL_LABELS = {'context_record__operation__cached_label': _(u"Operation")}
# search parameters
@@ -708,7 +711,8 @@ class ContextRecordSource(Source):
'context_record__datings__period__pk',
'context_record__unit': 'context_record__unit__pk',
}
- PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['context_record']
+ PARENT_SEARCH_VECTORS = BaseSource.PARENT_SEARCH_VECTORS + [
+ 'context_record']
class Meta:
verbose_name = _(u"Context record documentation")