diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-07-12 17:47:56 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-07-12 17:47:56 +0200 | 
| commit | 7185d81691ede9520cecdd2a2e8dcac372aaac6c (patch) | |
| tree | ed184fa6e4ea7b90928beb85f7b33588e9a33d40 /archaeological_operations/models.py | |
| parent | 3b3f4bb167226810a4d323488071bba22ae27621 (diff) | |
| download | Ishtar-7185d81691ede9520cecdd2a2e8dcac372aaac6c.tar.bz2 Ishtar-7185d81691ede9520cecdd2a2e8dcac372aaac6c.zip | |
Base public serializer
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 33 | 
1 files changed, 33 insertions, 0 deletions
| diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index a6e55a59e..336a9ca74 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -342,6 +342,24 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,      def short_class_name(self):          return _("SITE") +    def public_representation(self): +        dct = super(ArchaeologicalSite, self).public_representation() +        dct.update({ +            "reference": self.reference, +            "name": self.name, +            "materials": [str(p) for p in self.periods.all()], +            "remains": [str(r) for r in self.remains.all()], +            "towns": [t.label_with_areas() for t in self.towns.all()], +            "comment": self.comment, +            "locality": self.locality_ngi or self.locality_cadastral, +        }) +        profile = get_current_profile() +        if profile.underwater(): +            dct["shipwreck-name"] = self.shipwreck_name +            dct["sinking-date"] = self.sinking_date +            dct["discovery-area"] = self.discovery_area +        return dct +      @property      def finds(self):          from archaeological_finds.models import Find @@ -1068,6 +1086,21 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,          ]          return values +    def public_representation(self): +        dct = super(Operation, self).public_representation() +        dct.update({ +            "year": self.year, +            "common-name": self.common_name, +            "operation-type": self.operation_type and str(self.operation_type), +            "remains": [str(r) for r in self.remains.all()], +            "periods": [str(p) for p in self.periods.all()], +            "excavation-start-date": self.start_date, +            "excavation-end-date": self.excavation_end_date, +            "address": self.address, +            "comment": self.comment, +        }) +        return dct +      @classmethod      def _get_department_code(cls, value):          if not settings.ISHTAR_DPTS: | 
