summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
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
commit7185d81691ede9520cecdd2a2e8dcac372aaac6c (patch)
treeed184fa6e4ea7b90928beb85f7b33588e9a33d40 /archaeological_operations/models.py
parent3b3f4bb167226810a4d323488071bba22ae27621 (diff)
downloadIshtar-7185d81691ede9520cecdd2a2e8dcac372aaac6c.tar.bz2
Ishtar-7185d81691ede9520cecdd2a2e8dcac372aaac6c.zip
Base public serializer
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py33
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: