summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-22 16:44:40 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-04-24 19:38:56 +0200
commit2af3c31880b78d1b0110a168a9809c2c48111e40 (patch)
tree5b24e0c2251385e2237c5fed80d7354dceba2943 /archaeological_context_records/models.py
parent81a1008c26d0cc7cfdcbea14464746a7106d0e85 (diff)
downloadIshtar-2af3c31880b78d1b0110a168a9809c2c48111e40.tar.bz2
Ishtar-2af3c31880b78d1b0110a168a9809c2c48111e40.zip
Manage X, Y, Z fields for context records, operations and sites
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r--archaeological_context_records/models.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index cb6dbc635..89526076a 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -27,14 +27,15 @@ from django.utils.translation import ugettext_lazy as _, pgettext, \
activate, pgettext_lazy, deactivate
from django.utils.text import slugify
-from ishtar_common.utils import cached_label_changed, m2m_historization_changed
+from ishtar_common.utils import cached_label_changed, \
+ m2m_historization_changed, post_save_point
from ishtar_common.models import Document, GeneralType, \
BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \
GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\
post_save_cache, ValueGetter, BulkUpdatedItem, ExternalIdManager, \
RelationItem, Town, get_current_profile, document_attached_changed, \
- HistoryModel, SearchAltName
+ HistoryModel, SearchAltName, SpatialReferenceSystem
from archaeological_operations.models import Operation, Period, Parcel, \
ArchaeologicalSite
@@ -470,6 +471,18 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
verbose_name=_(u"Excavation technique"))
related_context_records = models.ManyToManyField(
'ContextRecord', through='RecordRelations', blank=True)
+ x = models.FloatField(_(u'X'), blank=True, null=True)
+ y = models.FloatField(_(u'Y'), blank=True, null=True)
+ z = models.FloatField(_(u'Z'), blank=True, null=True)
+ estimated_error_x = models.FloatField(_(u'Estimated error for X'),
+ blank=True, null=True)
+ estimated_error_y = models.FloatField(_(u'Estimated error for Y'),
+ blank=True, null=True)
+ estimated_error_z = models.FloatField(_(u'Estimated error for Z'),
+ blank=True, null=True)
+ spatial_reference_system = models.ForeignKey(
+ SpatialReferenceSystem, verbose_name=_(u"Spatial Reference System"),
+ blank=True, null=True)
point_2d = models.PointField(_(u"Point (2D)"), blank=True, null=True)
point = models.PointField(_(u"Point (3D)"), blank=True, null=True, dim=3)
multi_polygon = models.MultiPolygonField(_(u"Multi polygon"), blank=True,
@@ -510,6 +523,11 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
def __unicode__(self):
return self.short_label
+ def get_town_centroid(self):
+ if self.town:
+ return self.town.center
+ return self.operation.get_town_centroid()
+
@classmethod
def cached_label_bulk_update(cls, operation_id=None, parcel_id=None,
transaction_id=None):
@@ -732,7 +750,12 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
self.save()
-post_save.connect(cached_label_changed, sender=ContextRecord)
+def context_record_post_save(sender, **kwargs):
+ cached_label_changed(sender=sender, **kwargs)
+ post_save_point(sender=sender, **kwargs)
+
+
+post_save.connect(context_record_post_save, sender=ContextRecord)
m2m_changed.connect(document_attached_changed,
sender=ContextRecord.documents.through)