diff options
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 71 | 
1 files changed, 10 insertions, 61 deletions
| diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index b76e4841e..d79bce7f3 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -39,7 +39,7 @@ from ishtar_common.models import BaseHistorizedItem, Dashboard, \      post_delete_record_relation, post_save_cache, RelationItem, \      ShortMenuItem, SourceType, Town, ValueGetter, get_current_profile, \      document_attached_changed, HistoryModel, SearchAltName, \ -    SpatialReferenceSystem +    GeoItem  from ishtar_common.utils import cached_label_changed, \      force_cached_label_changed, mode, m2m_historization_changed, post_save_geo @@ -107,7 +107,7 @@ post_save.connect(post_save_cache, sender=RecordQualityType)  post_delete.connect(post_save_cache, sender=RecordQualityType) -class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, +class ArchaeologicalSite(BaseHistorizedItem, GeoItem, OwnPerms, ValueGetter,                           ShortMenuItem):      SHOW_URL = 'show-site'      TABLE_COLS = ['reference', 'name', 'towns_label', 'periods', 'remains'] @@ -262,32 +262,6 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,      drassm_number = models.CharField(_(u"DRASSM number"), max_length=100,                                       null=True, blank=True) -    # gis -    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 = 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"),          blank=True) @@ -403,15 +377,15 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,          q = self.towns.filter(center__isnull=False).annotate(                  centroid=Centroid(Union('center'))).all()          if not q.count(): -            return None -        return q.all()[0].centroid +            return +        return q.all()[0].centroid, self._meta.verbose_name      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 +            return +        return q.all()[0].poly, self._meta.verbose_name      def _get_base_image_path(self):          return u"{}/{}".format(self.SLUG, self.reference) @@ -535,7 +509,7 @@ class OperationManager(models.GeoManager):          return self.get(code_patriarche=txt_idx) -class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, +class Operation(ClosedItem, BaseHistorizedItem, GeoItem, OwnPerms, ValueGetter,                  ShortMenuItem, DashboardFormItem, RelationItem):      SHOW_URL = 'show-operation'      TABLE_COLS = ['year', 'towns_label', 'common_name', 'operation_type', @@ -946,31 +920,6 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,      name_of_the_protagonist = models.TextField(_(u"Name of the protagonist"),                                                 blank=True, null=True) -    # gis -    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 = 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: @@ -1141,15 +1090,15 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,          q = self.towns.filter(center__isnull=False).annotate(              centroid=Centroid(Union('center'))).all()          if not q.count(): -            return None -        return q.all()[0].centroid +            return +        return q.all()[0].centroid, self._meta.verbose_name      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 +        return q.all()[0].poly, self._meta.verbose_name      def context_record_relations_q(self):          from archaeological_context_records.models \ | 
