summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py36
1 files changed, 33 insertions, 3 deletions
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