diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-11-15 16:37:42 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:20:59 +0100 | 
| commit | e3ce9c77d36db4510076b677ec7ce1e0021a51f8 (patch) | |
| tree | edb1258d180c35e73a10ab7120c69d81b3925d44 /archaeological_operations/models.py | |
| parent | 905dfbb0ebb91af7b7acaae256306f178863c57f (diff) | |
| download | Ishtar-e3ce9c77d36db4510076b677ec7ce1e0021a51f8.tar.bz2 Ishtar-e3ce9c77d36db4510076b677ec7ce1e0021a51f8.zip | |
Syndication - serialization - display sheet operation
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 20 | 
1 files changed, 19 insertions, 1 deletions
| diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 050e50240..4747fbf9e 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -75,6 +75,7 @@ from ishtar_common.model_managers import UUIDModelManager  from ishtar_common.utils import (      cached_label_changed,      force_cached_label_changed, +    human_date,      mode,      m2m_historization_changed,      post_save_geo, @@ -732,6 +733,14 @@ def get_values_town_related(item, prefix, values, filtr=None):  class ClosedItem(object): +    def serialize_closing(self): +        value = self.closing() +        if not value: +            return "" +        value["date"] = human_date(value["date"]) +        value["user"] = str(value["user"]) +        return value +      def closing(self):          if self.is_active():              return @@ -1120,6 +1129,11 @@ class Operation(          "towns",          "periods",      ] +    SERIALIZE_PROPERTIES = MainItem.SERIALIZE_PROPERTIES + ["short_label"] +    SERIALIZE_DATES = ["start_date", "excavation_end_date"] +    SERIALIZE_CALL = {"closing": "serialize_closing", +                      "archaeological_sites_list": "archaeological_sites_list", +                      "documents_list": "documents_list"}      # fields definition      uuid = models.UUIDField(default=uuid.uuid4) @@ -1460,6 +1474,10 @@ class Operation(          )          return dct +    def archaeological_sites_list(self) -> list: +        return self.get_associated_main_item_list("archaeological_sites", +                                                  ArchaeologicalSite) +      @classmethod      def _get_department_code(cls, value):          if not settings.ISHTAR_DPTS: @@ -1499,7 +1517,7 @@ class Operation(          return [town.label_with_areas for town in self.towns.all()]      def towns_label(self): -        return " - ".join(self.towns_codes()) +        return " ; ".join(self.towns_codes())      def has_finds(self):          from archaeological_finds.models import BaseFind | 
