summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/migrations/0055_auto_20190521_1244.py165
-rw-r--r--archaeological_operations/models.py76
2 files changed, 234 insertions, 7 deletions
diff --git a/archaeological_operations/migrations/0055_auto_20190521_1244.py b/archaeological_operations/migrations/0055_auto_20190521_1244.py
new file mode 100644
index 000000000..72ac0d70c
--- /dev/null
+++ b/archaeological_operations/migrations/0055_auto_20190521_1244.py
@@ -0,0 +1,165 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.18 on 2019-05-21 12:44
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_operations', '0054_auto_20190225_1637'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='archaeologicalsite',
+ 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='archaeologicalsite',
+ name='cached_remains',
+ field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached remains label'),
+ ),
+ migrations.AddField(
+ model_name='archaeologicalsite',
+ name='cached_towns_label',
+ field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached town label'),
+ ),
+ migrations.AddField(
+ model_name='historicalarchaeologicalsite',
+ 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='historicalarchaeologicalsite',
+ name='cached_remains',
+ field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached remains label'),
+ ),
+ migrations.AddField(
+ model_name='historicalarchaeologicalsite',
+ name='cached_towns_label',
+ field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached town label'),
+ ),
+ migrations.AddField(
+ model_name='historicaloperation',
+ 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='historicaloperation',
+ name='cached_remains',
+ field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached remains label'),
+ ),
+ migrations.AddField(
+ model_name='historicaloperation',
+ name='cached_towns_label',
+ field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached town label'),
+ ),
+ migrations.AddField(
+ model_name='operation',
+ 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='operation',
+ name='cached_remains',
+ field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached remains label'),
+ ),
+ migrations.AddField(
+ model_name='operation',
+ name='cached_towns_label',
+ field=models.TextField(blank=True, help_text='Generated automatically - do not edit', null=True, verbose_name='Cached town label'),
+ ),
+ migrations.AlterField(
+ model_name='acttype',
+ name='intented_to',
+ field=models.CharField(choices=[('F', 'Dossier'), ('O', 'Opération'), ('TF', 'Demande de traitement'), ('T', 'Traitement')], max_length=2, verbose_name='Destiné à'),
+ ),
+ migrations.AlterField(
+ model_name='archaeologicalsite',
+ 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='archaeologicalsite',
+ 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='archaeologicalsite',
+ 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='archaeologicalsite',
+ 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='historicalarchaeologicalsite',
+ 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='historicalarchaeologicalsite',
+ 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='historicalarchaeologicalsite',
+ 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='historicalarchaeologicalsite',
+ 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='historicaloperation',
+ 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='historicaloperation',
+ 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='historicaloperation',
+ 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='historicaloperation',
+ 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='operation',
+ 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='operation',
+ 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='operation',
+ 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='operation',
+ 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_operations/models.py b/archaeological_operations/models.py
index 6b2cf4ec3..5bc730018 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -114,7 +114,19 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
APP = "archaeological-operations"
MODEL = "archaeological-site"
SHOW_URL = 'show-site'
- TABLE_COLS = ['reference', 'name', 'towns_label', 'periods', 'remains']
+ TABLE_COLS = ['reference', 'name', 'cached_towns_label',
+ 'cached_periods', 'cached_remains']
+ NEW_QUERY_ENGINE = True
+ COL_LABELS = {
+ 'cached_towns_label': _("Towns"),
+ 'cached_periods': _("Periods"),
+ 'cached_remains': _("Remains"),
+ }
+ EXTRA_REQUEST_KEYS = {
+ 'cached_towns_label': 'cached_towns_label',
+ 'cached_periods': 'cached_periods',
+ 'cached_remains': 'remains',
+ }
LONG_SLUG = 'archaeologicalsite'
STATISTIC_MODALITIES_OPTIONS = OrderedDict([
@@ -149,8 +161,6 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
DATED_FIELDS = ['sinking_date']
- COL_LABELS = {'towns_label': _("Towns")}
-
EXTRA_REQUEST_KEYS = {
'towns_label': 'towns',
'collaborators__pk': 'collaborators__pk', # dynamic_table_documents
@@ -242,6 +252,8 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
('operation', 'operations__pk'),
]
HISTORICAL_M2M = ['periods', 'remains', 'towns']
+ CACHED_LABELS = ['cached_label', 'cached_towns_label', 'cached_periods',
+ 'cached_remains']
# objects = SiteManager()
@@ -293,6 +305,18 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
verbose_name=_("Main image"), blank=True, null=True)
cached_label = models.TextField(_("Cached name"),
null=True, blank=True, db_index=True)
+ cached_towns_label = models.TextField(
+ _("Cached town label"), blank=True, null=True,
+ help_text=_("Generated automatically - do not edit")
+ )
+ cached_periods = models.TextField(
+ _("Cached periods label"), blank=True, null=True,
+ help_text=_("Generated automatically - do not edit")
+ )
+ cached_remains = models.TextField(
+ _("Cached remains label"), blank=True, null=True,
+ help_text=_("Generated automatically - do not edit")
+ )
history = HistoricalRecords(bases=[HistoryModel])
@@ -379,6 +403,15 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
]))
return name
+ def _generate_cached_towns_label(self):
+ return self.towns_label() or "-"
+
+ def _generate_cached_remains(self):
+ return " & ".join([str(remain) for remain in self.remains.all()]) or "-"
+
+ def _generate_cached_periods(self):
+ return " & ".join([str(period) for period in self.periods.all()]) or "-"
+
# def natural_key(self):
# return (self.reference, )
@@ -390,7 +423,7 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
return [town.label_with_areas for town in self.towns.all()]
def towns_label(self):
- return " - ".join(self.towns_codes())
+ return " & ".join(self.towns_codes())
def get_town_centroid(self):
q = self.towns.filter(center__isnull=False).annotate(
@@ -535,9 +568,10 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
APP = "archaeological-operations"
MODEL = "operation"
SHOW_URL = 'show-operation'
- TABLE_COLS = ['code_patriarche', 'year', 'towns_label', 'common_name',
- 'operation_type', 'start_date', 'excavation_end_date',
- 'remains']
+ TABLE_COLS = ['code_patriarche', 'year', 'cached_towns_label',
+ 'common_name', 'operation_type__label', 'start_date',
+ 'excavation_end_date', 'cached_remains']
+ NEW_QUERY_ENGINE = True
# statistics
STATISTIC_MODALITIES_OPTIONS = OrderedDict([
('year', _("Year")),
@@ -563,6 +597,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
'documentation_deadline__gte', 'finds_deadline__lte',
'finds_deadline__gte']
EXTRA_REQUEST_KEYS = {
+ 'operation_type__label': 'operation_type__label',
'common_name': 'common_name__icontains',
'cached_label': 'cached_label__icontains',
'comment': 'comment__icontains',
@@ -615,6 +650,10 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
'archaeological_sites__reference':
_("Archaeological sites (reference)"),
'towns_label': _("Towns"),
+ 'operation_type__label': _("Operation type"),
+ 'cached_towns_label': _("Towns"),
+ 'cached_periods': _("Periods"),
+ 'cached_remains': _("Remains"),
}
BASE_SEARCH_VECTORS = [
SearchVectorConfig("abstract", "local"),
@@ -657,6 +696,8 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
)
},
}
+ CACHED_LABELS = ['cached_label', 'cached_towns_label', 'cached_periods',
+ 'cached_remains']
objects = OperationManager()
# alternative names of fields for searches
@@ -967,6 +1008,18 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
blank=True, null=True)
name_of_the_protagonist = models.TextField(_("Name of the protagonist"),
blank=True, null=True)
+ cached_towns_label = models.TextField(
+ _("Cached town label"), blank=True, null=True,
+ help_text=_("Generated automatically - do not edit")
+ )
+ cached_periods = models.TextField(
+ _("Cached periods label"), blank=True, null=True,
+ help_text=_("Generated automatically - do not edit")
+ )
+ cached_remains = models.TextField(
+ _("Cached remains label"), blank=True, null=True,
+ help_text=_("Generated automatically - do not edit")
+ )
history = HistoricalRecords(bases=[HistoryModel])
@@ -1113,6 +1166,15 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
cached_label = settings.JOINT.join(items)
return cached_label
+ def _generate_cached_towns_label(self):
+ return self.towns_label() or "-"
+
+ def _generate_cached_remains(self):
+ return " & ".join([str(remain) for remain in self.remains.all()]) or "-"
+
+ def _generate_cached_periods(self):
+ return " & ".join([str(period) for period in self.periods.all()]) or "-"
+
def _get_associated_cached_labels(self):
return list(self.context_record.all())