summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2023-01-19 20:47:06 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2023-01-19 20:47:06 +0100
commitf5a0acf2638ce5bb31e1e9750f30fbc52cae1577 (patch)
treef7f66957278e35bacd7298ed22fa5f383e1689b7
parentd09a5199a6456b9ee061842a857870b6b41c656d (diff)
downloadIshtar-f5a0acf2638ce5bb31e1e9750f30fbc52cae1577.tar.bz2
Ishtar-f5a0acf2638ce5bb31e1e9750f30fbc52cae1577.zip
Sheet find refactoring
-rw-r--r--archaeological_finds/models_finds.py13
-rw-r--r--archaeological_finds/templates/ishtar/sheet_basefind.html24
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html73
3 files changed, 57 insertions, 53 deletions
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 %}
+
+ <div class="clearfix">
+ </div>
+ <h3>{% trans "Geographic localisation" %}</h3>
+ <div class='row'>
+ {% with geo_item=base_find %}
+ {% include "ishtar/blocks/sheet_map.html"%}
+ {% endwith %}
+ </div>
+ <div class="row">
+ {% field_flex_full "Point of topographic reference" base_find.topographic_localisation %}
+ </div>
{% if not is_external %}
<h3>{% trans "Sheet"%}</h3>
<div class='row'>
@@ -64,17 +76,5 @@
{% endif %}
</div>
{% endif %}
-
- <div class="clearfix">
- </div>
- <h3>{% trans "Geographic localisation" %}</h3>
- <div class='row'>
- {% with geo_item=base_find %}
- {% include "ishtar/blocks/sheet_map.html"%}
- {% endwith %}
- </div>
- <div class="row">
- {% field_flex_full "Point of topographic reference" base_find.topographic_localisation %}
- </div>
</div>
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 @@
<a class="nav-link" id="{{window_id}}-identification-tab"
data-toggle="tab" href="#{{window_id}}-identification" role="tab"
aria-controls="{{window_id}}-identification" aria-selected="false">
- {% trans "Identification / Description / Dimensions" %}
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link" id="{{window_id}}-preservation-tab"
- data-toggle="tab" href="#{{window_id}}-preservation" role="tab"
- aria-controls="{{window_id}}-preservation" aria-selected="false">
- {% trans "Datings / Preservation" %}
+ {% trans "Identification / Description" %}
</a>
</li>
{% if display_warehouse_treatments %}
@@ -60,7 +53,7 @@
<a class="nav-link" id="{{window_id}}-warehouse-tab"
data-toggle="tab" href="#{{window_id}}-warehouse" role="tab"
aria-controls="{{window_id}}-warehouse" aria-selected="false">
- {% trans "Warehouse / Treatments" %}
+ {% trans "Preservation / Treatments" %}
</a>
</li>
{% endif %}
@@ -180,7 +173,9 @@
{% field_flex_full "Description" item.description "<pre>" "</pre>" %}
{% field_flex_full "Public description" item.public_description "<pre>" "</pre>" %}
{% 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 "<pre>" "</pre>" %}
{% field_flex_multiple_obj "Object types" item 'object_types' %}
@@ -214,42 +209,12 @@
</div>
{% endif %}
- <h3>{% trans "Sheet" %}</h3>
- <div class='row'>
- {% 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" %}
- </div>
- </div>
- <div class="tab-pane fade" id="{{window_id}}-preservation"
- role="tabpanel" aria-labelledby="{{window_id}}-preservation-tab">
{% 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 %}
- <h3>{% trans "Preservation" %}</h3>
- <div class='row'>
- {% 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 "<pre>" "</pre>" %}
- </div>
- {% elif not dating_list and not item.dating_comment and not item.cultural_attributions_count %}
- <div class="alert alert-info" role="alert">
- {% trans "No datation or preservation info." %}
- </div>
- {% endif %}
{% if dating_list or item.dating_comment or item.cultural_attributions_count %}
<h3>{% trans "Dating" %}</h3>
{% if item.cultural_attributions_count %}
<div class='row'>
- {% field_flex_multiple_obj "Cultural attributions" item 'cultural_attributions' %}
+ {% field_flex_multiple_obj "Cultural attributions" item 'cultural_attributions' %}
</div>
{% endif %}
<table id='{{window_id}}-datings' class="table table-striped">
@@ -289,6 +254,16 @@
</div>
{% endif %}
{% endwith %}
+
+ <h3>{% trans "Sheet" %}</h3>
+ <div class='row'>
+ {% 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" %}
+ </div>
</div>
{% if display_warehouse_treatments %}
<div class="tab-pane fade" id="{{window_id}}-warehouse"
@@ -300,6 +275,22 @@
</div>
{% 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 %}
+ <h3>{% trans "Preservation" %}</h3>
+ <div class='row'>
+ {% 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 "<pre>" "</pre>" %}
+ </div>
+ {% endif %}
{% if item.container or item.container_ref %}
{% if can_view_container %}
<h3>{% trans "Warehouse - container" %}</h3>