From 931092752a4db520becea7815e0d1e205b0a921e Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 19 Jan 2023 20:47:06 +0100 Subject: Sheet find refactoring --- archaeological_finds/models_finds.py | 13 ++++ .../templates/ishtar/sheet_basefind.html | 24 +++---- .../templates/ishtar/sheet_find.html | 73 ++++++++++------------ 3 files changed, 57 insertions(+), 53 deletions(-) (limited to 'archaeological_finds') diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 11c611eea..05321be50 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -2230,6 +2230,19 @@ class Find( materials.add(material) return ", ".join(sorted(materials)) + def get_hierarchical_material_types(self) -> str: + """ + Return comma separated string of material types with full hierarchy + """ + labels = [] + for material in self.material_types.all(): + mat = [material.label] + while material.parent: + mat.append(material.parent.label) + material = material.parent + labels.append(" > ".join([m for m in reversed(mat)])) + return " ; ".join(sorted(labels)) + def get_material_types_recommendations(self) -> str: """ Return comma separated string of recommendations from material diff --git a/archaeological_finds/templates/ishtar/sheet_basefind.html b/archaeological_finds/templates/ishtar/sheet_basefind.html index fb67e3cd8..f3b200fe4 100644 --- a/archaeological_finds/templates/ishtar/sheet_basefind.html +++ b/archaeological_finds/templates/ishtar/sheet_basefind.html @@ -48,6 +48,18 @@ {% with item=base_find %} {% include "ishtar/blocks/sheet_json.html" %} {% endwith %} + +
+
+

{% trans "Geographic localisation" %}

+
+ {% with geo_item=base_find %} + {% include "ishtar/blocks/sheet_map.html"%} + {% endwith %} +
+
+ {% field_flex_full "Point of topographic reference" base_find.topographic_localisation %} +
{% if not is_external %}

{% trans "Sheet"%}

@@ -64,17 +76,5 @@ {% endif %}
{% endif %} - -
-
-

{% trans "Geographic localisation" %}

-
- {% with geo_item=base_find %} - {% include "ishtar/blocks/sheet_map.html"%} - {% endwith %} -
-
- {% field_flex_full "Point of topographic reference" base_find.topographic_localisation %} -
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index 20cb4a5c1..e6856dd53 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -45,14 +45,7 @@ - {% trans "Identification / Description / Dimensions" %} - - - {% if display_warehouse_treatments %} @@ -60,7 +53,7 @@ - {% trans "Warehouse / Treatments" %} + {% trans "Preservation / Treatments" %} {% endif %} @@ -180,7 +173,9 @@ {% field_flex_full "Description" item.description "
" "
" %} {% field_flex_full "Public description" item.public_description "
" "
" %} {% field_flex "Is complete?" item.is_complete %} - {% field_flex_multiple_obj "Material types" item 'material_types' %} + {% with material=item.get_hierarchical_material_types %}{% if material %} + {% field_flex "Material types" material %} + {% endif %}{% endwith %} {% field_flex "Material type quality" item.material_type_quality %} {% field_flex_full "Comment on the material" item.material_comment "
" "
" %} {% field_flex_multiple_obj "Object types" item 'object_types' %} @@ -214,42 +209,12 @@ {% endif %} -

{% trans "Sheet" %}

-
- {% trans "Checked" as checked_label %} - {% field_flex checked_label item.checked_type %} - {% field_flex "Check date" item.check_date %} - {% include "ishtar/blocks/sheet_creation_section.html" %} -
- -
{% with dating_list=item|m2m_listing:"datings" %} - {% if item.integrities_count or item.remarkabilities_count or item.conservatory_state or item.conservatory_comment or item.alterations.count or item.alteration_causes.count or item.preservation_to_considers.count or item.appraisal_date or item.treatment_emergency or item.insurance_value or item.estimated_value %} -

{% trans "Preservation" %}

-
- {% field_flex_multiple_obj "Integrity / interest" item 'integrities' %} - {% field_flex_multiple_obj "Remarkability" item 'remarkabilities' %} - {% field_flex "Conservatory state" item.conservatory_state %} - {% field_flex_multiple_obj "Alteration" item 'alterations' %} - {% field_flex_multiple_obj "Alteration cause" item 'alteration_causes' %} - {% field_flex_multiple_obj "Recommended treatments" item 'preservation_to_considers' %} - {% field_flex "Treatment emergency" item.treatment_emergency %} - {% field_flex "Estimated value" item.estimated_value|default_if_none:''|intcomma '' ' '|add:CURRENCY %} - {% field_flex "Insurance value" item.insurance_value|default_if_none:''|intcomma '' ' '|add:CURRENCY %} - {% field_flex "Appraisal date" item.appraisal_date %} - {% field_flex_full "Conservatory comment" item.conservatory_comment "
" "
" %} -
- {% elif not dating_list and not item.dating_comment and not item.cultural_attributions_count %} - - {% endif %} {% if dating_list or item.dating_comment or item.cultural_attributions_count %}

{% trans "Dating" %}

{% if item.cultural_attributions_count %}
- {% field_flex_multiple_obj "Cultural attributions" item 'cultural_attributions' %} + {% field_flex_multiple_obj "Cultural attributions" item 'cultural_attributions' %}
{% endif %} @@ -289,6 +254,16 @@ {% endif %} {% endwith %} + +

{% trans "Sheet" %}

+
+ {% trans "Checked" as checked_label %} + {% field_flex checked_label item.checked_type %} + {% with item.check_date|date:"SHORT_DATE_FORMAT" as check_date %} + {% if check_date %}{% field_flex "Check date" check_date %}{% endif %} + {% endwith %} + {% include "ishtar/blocks/sheet_creation_section.html" %} +
{% if display_warehouse_treatments %}
{% endif %} {% endcomment %} + {% if item.integrities_count or item.remarkabilities_count or item.conservatory_state or item.conservatory_comment or item.alterations.count or item.alteration_causes.count or item.preservation_to_considers.count or item.appraisal_date or item.treatment_emergency or item.insurance_value or item.estimated_value %} +

{% trans "Preservation" %}

+
+ {% field_flex_multiple_obj "Integrity / interest" item 'integrities' %} + {% field_flex_multiple_obj "Remarkability" item 'remarkabilities' %} + {% field_flex "Conservatory state" item.conservatory_state %} + {% field_flex_multiple_obj "Alteration" item 'alterations' %} + {% field_flex_multiple_obj "Alteration cause" item 'alteration_causes' %} + {% field_flex_multiple_obj "Recommended treatments" item 'preservation_to_considers' %} + {% field_flex "Treatment emergency" item.treatment_emergency %} + {% field_flex "Estimated value" item.estimated_value|default_if_none:''|intcomma '' ' '|add:CURRENCY %} + {% field_flex "Insurance value" item.insurance_value|default_if_none:''|intcomma '' ' '|add:CURRENCY %} + {% field_flex "Appraisal date" item.appraisal_date %} + {% field_flex_full "Conservatory comment" item.conservatory_comment "
" "
" %} +
+ {% endif %} {% if item.container or item.container_ref %} {% if can_view_container %}

{% trans "Warehouse - container" %}

-- cgit v1.2.3