From c641fca2bc2bd5c6892b4105325dee99e9da35d6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 18 May 2022 16:24:26 +0200 Subject: Syndication - serialization - display sheet find - 2 --- archaeological_context_records/models.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'archaeological_context_records/models.py') diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index ef9e2788e..29e8793dc 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -66,7 +66,7 @@ from ishtar_common.models import ( QuickAction, RelationsViews, ) -from ishtar_common.models_common import HistoricalRecords +from ishtar_common.models_common import HistoricalRecords, SerializeItem from archaeological_operations.models import ( Operation, Period, @@ -98,7 +98,9 @@ post_save.connect(post_save_cache, sender=DatingQuality) post_delete.connect(post_save_cache, sender=DatingQuality) -class Dating(models.Model): +class Dating(models.Model, SerializeItem): + SLUG = "dating" + SERIALIZE_EXCLUDE = ["find", "context_record"] uuid = models.UUIDField(default=uuid.uuid4) period = models.ForeignKey( Period, verbose_name=_("Period"), on_delete=models.PROTECT @@ -614,6 +616,10 @@ class ContextRecord( ), ] SERIALIZE_EXCLUDE = MainItem.SERIALIZE_EXCLUDE + ["contextrecord"] + SERIALIZE_PROPERTIES = MainItem.SERIALIZE_PROPERTIES + [ + "short_label", + "town_label_with_areas", + ] history = HistoricalRecords(bases=[HistoryModel]) objects = UUIDModelManager() @@ -974,6 +980,12 @@ class ContextRecord( ] ) + @property + def town_label_with_areas(self): + if not self.town: + return "" + return self.town.label_with_areas + @property def relation_label(self): return self.label -- cgit v1.2.3