diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-27 17:11:00 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:28 +0200 |
commit | 0ee38b3dcae7811bae1cdbf5531cc252a310335d (patch) | |
tree | fca483b4ad7b35ffabf5b1ea1b2b7837ee8eab08 | |
parent | 5496c7fdf724087ce8c0ffc1c705fc57947beaec (diff) | |
download | Ishtar-0ee38b3dcae7811bae1cdbf5531cc252a310335d.tar.bz2 Ishtar-0ee38b3dcae7811bae1cdbf5531cc252a310335d.zip |
Context records: settings for new query engine
-rw-r--r-- | archaeological_context_records/migrations/0045_auto_20190527_1645.py | 70 | ||||
-rw-r--r-- | archaeological_context_records/models.py | 18 |
2 files changed, 85 insertions, 3 deletions
diff --git a/archaeological_context_records/migrations/0045_auto_20190527_1645.py b/archaeological_context_records/migrations/0045_auto_20190527_1645.py new file mode 100644 index 000000000..f88bdd805 --- /dev/null +++ b/archaeological_context_records/migrations/0045_auto_20190527_1645.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-05-27 16:45 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_context_records', '0044_auto_20190225_1637'), + ] + + operations = [ + migrations.AddField( + model_name='contextrecord', + name='cached_periods', + field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached periods label'), + ), + migrations.AddField( + model_name='historicalcontextrecord', + name='cached_periods', + field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached periods label'), + ), + migrations.AlterField( + model_name='contextrecord', + name='multi_polygon_source', + field=models.CharField(blank=True, choices=[('T', 'Commune'), ('P', 'Précis'), ('M', 'Polygone')], max_length=1, null=True, verbose_name='Source du multi-polygone'), + ), + migrations.AlterField( + model_name='contextrecord', + name='multi_polygon_source_item', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Élément source du multi-polygone'), + ), + migrations.AlterField( + model_name='contextrecord', + name='point_source', + field=models.CharField(blank=True, choices=[('T', 'Commune'), ('P', 'Précis'), ('M', 'Polygone')], max_length=1, null=True, verbose_name='Source du point'), + ), + migrations.AlterField( + model_name='contextrecord', + name='point_source_item', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Élément source du point'), + ), + migrations.AlterField( + model_name='historicalcontextrecord', + name='multi_polygon_source', + field=models.CharField(blank=True, choices=[('T', 'Commune'), ('P', 'Précis'), ('M', 'Polygone')], max_length=1, null=True, verbose_name='Source du multi-polygone'), + ), + migrations.AlterField( + model_name='historicalcontextrecord', + name='multi_polygon_source_item', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Élément source du multi-polygone'), + ), + migrations.AlterField( + model_name='historicalcontextrecord', + name='point_source', + field=models.CharField(blank=True, choices=[('T', 'Commune'), ('P', 'Précis'), ('M', 'Polygone')], max_length=1, null=True, verbose_name='Source du point'), + ), + migrations.AlterField( + model_name='historicalcontextrecord', + name='point_source_item', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Élément source du point'), + ), + migrations.AlterField( + model_name='relationtype', + name='logical_relation', + field=models.CharField(blank=True, choices=[('above', 'Au-dessus'), ('bellow', 'En dessous'), ('equal', 'Égal')], max_length=10, null=True, verbose_name='Relation logique'), + ), + ] diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 3b5e24602..1b63af51a 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -283,12 +283,14 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, EXTERNAL_ID_KEY = 'context_record_external_id' EXTERNAL_ID_DEPENDENCIES = ['base_finds'] TABLE_COLS = ['label', 'operation__common_name', 'town__name', - 'parcel__cached_label', 'unit'] + 'parcel__cached_label', 'unit__label'] if settings.COUNTRY == 'fr': TABLE_COLS.insert(1, 'operation__code_patriarche') - TABLE_COLS_FOR_OPE = ['label', 'parcel', 'unit', - 'datings__period__label', 'description'] + TABLE_COLS_FOR_OPE = ['label', 'parcel', 'unit__label', + 'cached_periods', 'description'] + NEW_QUERY_ENGINE = True COL_LABELS = { + 'cached_periods': _("Periods"), 'datings__period__label': _("Periods"), 'datings__period': _("Datings (period)"), 'detailled_related_context_records': _("Related context records"), @@ -337,6 +339,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, 'cached_label': 'cached_label__icontains', 'datings__period__label': 'datings__period__label', 'operation_id': 'operation_id', + 'unit__label': "unit__label" } RELATION_TYPES_PREFIX = {'ope_relation_types': 'operation__', 'cr_relation_types': ''} @@ -424,6 +427,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, HISTORICAL_M2M = [ 'datings', 'documentations' ] + CACHED_LABELS = ['cached_label', 'cached_periods'] history = HistoricalRecords(bases=[HistoryModel]) objects = ExternalIdManager() @@ -508,6 +512,10 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, verbose_name=_("Main image"), blank=True, null=True) cached_label = models.TextField(_("Cached name"), null=True, blank=True, db_index=True) + cached_periods = models.TextField( + _("Cached periods label"), blank=True, null=True, + help_text=_("Generated automatically - do not edit") + ) class Meta: verbose_name = _("Context Record") @@ -704,6 +712,10 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, def _generate_cached_label(self): return self.full_label() + def _generate_cached_periods(self): + return " & ".join([dating.period.label + for dating in self.datings.all()]) + def _get_associated_cached_labels(self): from archaeological_finds.models import Find, BaseFind return list(Find.objects.filter(base_finds__context_record=self).all())\ |