From 934fe4b6b080a7563119d40f4ef5ce6d7c7a3254 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 31 Mar 2026 16:47:28 +0200 Subject: ✨ sites - sheet: add heritage fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_operations/models.py | 25 ++++++------- .../templates/ishtar/sheet_site.html | 41 +++++++++++++++------- ishtar_common/models_common.py | 6 ++++ 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index d2f6861ed..62c0bcf93 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1042,22 +1042,23 @@ class ArchaeologicalSite( return self.towns_label() or "-" def _generate_cached_remains(self): - q = self.remains - if not self.remains.exists(): - return "-" - return " & ".join(list(q.values_list("label", flat=True))) + return self._regenerate_many_to_many_for_cache("remains") def _generate_cached_periods(self): - q = self.periods - if not self.periods.exists(): - return "-" - return " & ".join(list(q.values_list("label", flat=True))) + return self._regenerate_many_to_many_for_cache("periods") def _generate_cached_types(self): - q = self.types - if not self.types.exists(): - return "-" - return " & ".join(list(q.values_list("label", flat=True))) + return self._regenerate_many_to_many_for_cache("types") + + def _generate_cached_current_states(self): + return self._regenerate_many_to_many_for_cache("current_states") + + def _generate_cached_heritage_interests(self): + return self._regenerate_many_to_many_for_cache("heritage_interests") + + def _generate_cached_heritage_environmental_protections(self): + return self._regenerate_many_to_many_for_cache( + "heritage_environmental_protections") def natural_key(self): return (self.reference,) diff --git a/archaeological_operations/templates/ishtar/sheet_site.html b/archaeological_operations/templates/ishtar/sheet_site.html index 2deb54683..6600dd7ed 100644 --- a/archaeological_operations/templates/ishtar/sheet_site.html +++ b/archaeological_operations/templates/ishtar/sheet_site.html @@ -40,16 +40,9 @@

{% trans "General"%}

- {% field_flex "Other reference" item.other_reference %} - {% field_flex_multiple_obj _("Types") item 'types' %} - {% field_flex _("Discovery status") item.discovery_status %} - {% field_flex _("Current status") item.current_status %} - {% field_flex _("Nature of site") item.nature_of_site %} - {% field_flex _("Interpretation level") item.interpretation_level %} - {% field_flex_multiple_obj "Periods" item 'periods' %} - {% field_flex_multiple_obj "Remains" item 'remains' %} - {% field_flex_multiple_obj "Cultural attributions" item 'cultural_attributions' %} - {% field_flex_detail _("Discoverer") item.discoverer %} + {% field_flex _("Other reference") item.other_reference %} + {% field_flex_multiple_obj _("Heritage interest") item 'heritage_interests' %} + {% field_flex_detail_multiple _("Actors") item.actors %} {% field_flex_detail_multiple _("Collaborators") item.collaborators %} {% if item.description == item.public_description %} {% field_flex_full _("Description/Public description") item.description "
" "
" %} @@ -57,8 +50,31 @@ {% field_flex_full _("Description") item.description "
" "
" %} {% field_flex_full _("Public description") item.public_description "
" "
" %} {% endif %} - {% field_flex_full "Comment" item.comment "
" "
" %} + {% field_flex_full _("Comment") item.comment "
" "
" %} +
+{% if item.cached_types or item.nature_of_site or item.interpretation_level or item.discovery_status or item.cached_current_states or item.cached_periods or item.cached_remains or item.cultural_attributions.count or item.discoverer %} +

{% trans "Scientific" %}

+
+ {% field_flex_multiple_obj _("Types") item 'types' %} + {% field_flex _("Nature of site") item.nature_of_site %} + {% field_flex _("Interpretation level") item.interpretation_level %} + {% field_flex _("Discovery status") item.discovery_status %} + {% field_flex_multiple_obj _("Current states") item 'current_states' %} + {% field_flex_multiple_obj _("Periods") item 'periods' %} + {% field_flex_multiple_obj _("Remains") item 'remains' %} + {% field_flex_multiple_obj _("Cultural attributions") item 'cultural_attributions' %} + {% field_flex_detail _("Discoverer") item.discoverer %}
+{% endif %} +{% if item.cached_heritage_environmental_protections or item.details_on_protection or item.protection_id or item.protection_date %} +

{% trans "Protection" %}

+
+ {% field_flex _("Protection ID") item.protection_id %} + {% field_flex _("Protection date") item.protection_date|date:"DATE_FORMAT" %} + {% field_flex_multiple_obj _("Heritage and environmental protections") item 'heritage_environmental_protections' %} + {% field_flex_full _("Details on protection") item.details_on_protection "
" "
" %} +
+{% endif %} {% if item.affmar_number or item.drassm_number or item.oceanographic_service_localisation or item.shipwreck_code or item.sinking_date or item.discovery_area or item.shipwreck_name %}

{% trans "Underwater"%}

@@ -128,9 +144,10 @@ {% endif %} {% if not is_external %} -{% if item.history_creator or item.last_edition_date or item.created %} +{% if item.history_creator or item.last_edition_date or item.created or item.editors.count %}

{% trans "Sheet"%}

+ {% field_flex_multiple _("Editors") item.editors %} {% include "ishtar/blocks/sheet_creation_section.html" %}
{% endif %} diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index a2708945f..ba27b3bbc 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -3707,6 +3707,12 @@ class MainItem(ShortMenuItem, SerializeItem, SheetItem): return actions + def _regenerate_many_to_many_for_cache(self, attr): + q = getattr(self, attr) + if not q.exists(): + return "-" + return " & ".join(list(q.values_list("label", flat=True))) + class TownManager(models.Manager): def get_by_natural_key(self, numero_insee, year): -- cgit v1.2.3