summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r--archaeological_context_records/models.py51
1 files changed, 23 insertions, 28 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 71551a49d..a2793ac67 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -35,7 +35,7 @@ from ishtar_common.models import Document, GeneralType, \
GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\
post_save_cache, ValueGetter, BulkUpdatedItem, ExternalIdManager, \
RelationItem, Town, get_current_profile, document_attached_changed, \
- HistoryModel, SearchAltName, SpatialReferenceSystem
+ HistoryModel, SearchAltName, GeoItem
from archaeological_operations.models import Operation, Period, Parcel, \
ArchaeologicalSite
@@ -269,7 +269,7 @@ class CRBulkView(object):
"""
-class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
+class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, GeoItem,
OwnPerms, ValueGetter, ShortMenuItem, RelationItem):
SHOW_URL = 'show-contextrecord'
SLUG = 'contextrecord'
@@ -471,30 +471,7 @@ 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)
- 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='context_records', verbose_name=_(u"Documents"),
blank=True)
@@ -533,14 +510,32 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
def get_town_centroid(self):
if self.town:
- return self.town.center
+ return self.town.center, self._meta.verbose_name
+ if self.archaeological_site:
+ centroid = self.archaeological_site.get_town_centroid()
+ if centroid:
+ return centroid
return self.operation.get_town_centroid()
def get_town_polygons(self):
if self.town:
- return self.town.limit
+ return self.town.limit, self._meta.verbose_name
+ if self.archaeological_site:
+ polys = self.archaeological_site.get_town_centroid()
+ if polys:
+ return polys
return self.operation.get_town_polygons()
+ def get_precise_points(self):
+ precise_points = super(ContextRecord, self).get_precise_points()
+ if precise_points:
+ return precise_points
+ if self.archaeological_site:
+ precise_points = self.archaeological_site.get_precise_points()
+ if precise_points:
+ return precise_points
+ return self.operation.get_precise_points()
+
@classmethod
def cached_label_bulk_update(cls, operation_id=None, parcel_id=None,
transaction_id=None):