summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/migrations/0050_auto_20190206_1423.py55
-rw-r--r--archaeological_operations/models.py36
2 files changed, 88 insertions, 3 deletions
diff --git a/archaeological_operations/migrations/0050_auto_20190206_1423.py b/archaeological_operations/migrations/0050_auto_20190206_1423.py
new file mode 100644
index 000000000..a632b6059
--- /dev/null
+++ b/archaeological_operations/migrations/0050_auto_20190206_1423.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2019-02-06 14:23
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_operations', '0049_auto_20190122_1621'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='archaeologicalsite',
+ name='multi_polygon_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Multi-polygon source'),
+ ),
+ migrations.AddField(
+ model_name='archaeologicalsite',
+ name='point_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Point source'),
+ ),
+ migrations.AddField(
+ model_name='historicalarchaeologicalsite',
+ name='multi_polygon_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Multi-polygon source'),
+ ),
+ migrations.AddField(
+ model_name='historicalarchaeologicalsite',
+ name='point_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Point source'),
+ ),
+ migrations.AddField(
+ model_name='historicaloperation',
+ name='multi_polygon_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Multi-polygon source'),
+ ),
+ migrations.AddField(
+ model_name='historicaloperation',
+ name='point_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Point source'),
+ ),
+ migrations.AddField(
+ model_name='operation',
+ name='multi_polygon_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Multi-polygon source'),
+ ),
+ migrations.AddField(
+ model_name='operation',
+ name='point_source',
+ field=models.CharField(blank=True, choices=[(b'T', 'Commune'), (b'P', 'Precise')], max_length=1, null=True, verbose_name='Point source'),
+ ),
+ ]
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index a8f1d4faf..2335155ed 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -41,7 +41,7 @@ from ishtar_common.models import BaseHistorizedItem, Dashboard, \
document_attached_changed, HistoryModel, SearchAltName, \
SpatialReferenceSystem
from ishtar_common.utils import cached_label_changed, \
- force_cached_label_changed, mode, m2m_historization_changed, post_save_point
+ force_cached_label_changed, mode, m2m_historization_changed, post_save_geo
class RemainType(GeneralType):
@@ -277,8 +277,16 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,
blank=True, null=True)
point = models.PointField(_(u"Point"), blank=True, null=True, dim=3)
point_2d = models.PointField(_(u"Point (2D)"), blank=True, null=True)
+ point_source = models.CharField(
+ _(u"Point source"),
+ choices=(('T', _(u"Town")), ('P', _(u"Precise"))), max_length=1,
+ blank=True, null=True)
multi_polygon = models.MultiPolygonField(_(u"Multi polygon"), blank=True,
null=True)
+ multi_polygon_source = models.CharField(
+ _(u"Multi-polygon source"),
+ choices=(('T', _(u"Town")), ('P', _(u"Precise"))), max_length=1,
+ blank=True, null=True)
documents = models.ManyToManyField(
Document, related_name="sites", verbose_name=_(u"Documents"),
@@ -392,6 +400,13 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,
return None
return q.all()[0].centroid
+ def get_town_polygons(self):
+ q = self.towns.filter(limit__isnull=False).annotate(
+ poly=Union('limit')).all()
+ if not q.count():
+ return None
+ return q.all()[0].poly
+
def _get_base_image_path(self):
return u"{}/{}".format(self.SLUG, self.reference)
@@ -447,7 +462,7 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,
def site_post_save(sender, **kwargs):
cached_label_changed(sender=sender, **kwargs)
- post_save_point(sender=sender, **kwargs)
+ post_save_geo(sender=sender, **kwargs)
post_save.connect(site_post_save, sender=ArchaeologicalSite)
@@ -940,8 +955,16 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
blank=True, null=True)
point = models.PointField(_(u"Point"), blank=True, null=True, dim=3)
point_2d = models.PointField(_(u"Point (2D)"), blank=True, null=True)
+ point_source = models.CharField(
+ _(u"Point source"),
+ choices=(('T', _(u"Town")), ('P', _(u"Precise"))), max_length=1,
+ blank=True, null=True)
multi_polygon = models.MultiPolygonField(_(u"Multi polygon"), blank=True,
null=True)
+ multi_polygon_source = models.CharField(
+ _(u"Multi-polygon source"),
+ choices=(('T', _(u"Town")), ('P', _(u"Precise"))), max_length=1,
+ blank=True, null=True)
history = HistoricalRecords(bases=[HistoryModel])
class Meta:
@@ -1115,6 +1138,13 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
return None
return q.all()[0].centroid
+ def get_town_polygons(self):
+ q = self.towns.filter(limit__isnull=False).annotate(
+ poly=Union('limit')).all()
+ if not q.count():
+ return None
+ return q.all()[0].poly
+
def context_record_relations_q(self):
from archaeological_context_records.models \
import RecordRelations as CRRL
@@ -1464,7 +1494,7 @@ for attr in Operation.HISTORICAL_M2M:
def operation_post_save(sender, **kwargs):
if not kwargs['instance']:
return
- post_save_point(sender=sender, **kwargs)
+ post_save_geo(sender=sender, **kwargs)
operation = kwargs['instance']
operation.skip_history_when_saving = True