summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models_finds.py47
-rw-r--r--archaeological_finds/templates/ishtar/sheet_basefind.html6
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html47
3 files changed, 82 insertions, 18 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 6ccf6c990..583ee405a 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -395,6 +395,9 @@ class BaseFind(
EXTERNAL_ID_KEY = "base_find_external_id"
EXTERNAL_ID_DEPENDENCIES = ["find"]
SLUG = "basefind"
+ SERIALIZE_EXCLUDE = ["find"]
+ SERIALIZE_CALL = {"complete_id": "complete_id", "short_id": "short_id"}
+
uuid = models.UUIDField(default=uuid.uuid4)
label = models.TextField(_("Free ID"))
external_id = models.TextField(_("External ID"), blank=True, default="")
@@ -1759,9 +1762,20 @@ class Find(
"cached_object_types",
"cached_materials",
]
- SERIALIZE_PROPERTIES = ["external_id"]
- SERIALIZE_CALL = {"base_finds_list": "base_finds_list",
- "documents_list": "documents_list"}
+ SERIALIZE_CALL = {
+ "base_finds_list": "base_finds_list",
+ "documents_list": "documents_list",
+ "m2m_listing_datings": "m2m_listing_datings",
+ }
+ SERIALIZE_PROPERTIES = MainItem.SERIALIZE_PROPERTIES + [
+ "administrative_index",
+ "integrities_count",
+ "remarkabilities_count",
+ "cultural_attributions_count",
+ "documents_count",
+ "excavation_ids",
+ "weight_string",
+ ]
objects = UUIDModelManager()
# fields
@@ -2161,6 +2175,9 @@ class Find(
lst.append(bf.full_serialize())
return lst
+ def m2m_listing_datings(self) -> list:
+ return [dating.full_serialize() for dating in self.datings.all()]
+
DOC_VALUES = [
("base_finds", _("List of associated base finds")),
("material_types_label", _("Material types string")),
@@ -2209,7 +2226,8 @@ class Find(
q = q.exclude(**{k: v})
for recommendation in q.values_list(
- "parent__" * level + "recommendation", flat=True):
+ "parent__" * level + "recommendation", flat=True
+ ):
recommendations.add(recommendation)
return ", ".join(sorted(recommendations))
@@ -2225,8 +2243,9 @@ class Find(
if not filtr or prefix + "material_types_code" in filtr:
values[prefix + "material_types_code"] = self.get_material_types_code()
if not filtr or prefix + "material_types_recommendations" in filtr:
- values[prefix + "material_types_recommendations"] = \
- self.get_material_types_recommendations()
+ values[
+ prefix + "material_types_recommendations"
+ ] = self.get_material_types_recommendations()
if no_base_finds:
return values
# by default attach first basefind data
@@ -2337,6 +2356,22 @@ class Find(
return "{}-{}".format(bf.context_record.operation.get_reference(), self.index)
@property
+ def integrities_count(self):
+ return self.integrities.count()
+
+ @property
+ def remarkabilities_count(self):
+ return self.remarkabilities.count()
+
+ @property
+ def cultural_attributions_count(self):
+ return self.cultural_attributions.count()
+
+ @property
+ def documents_count(self):
+ return self.documents.count()
+
+ @property
def operation(self):
bf = self.get_first_base_find()
if not bf or not bf.context_record or not bf.context_record.operation:
diff --git a/archaeological_finds/templates/ishtar/sheet_basefind.html b/archaeological_finds/templates/ishtar/sheet_basefind.html
index c57e0d681..0b56727ca 100644
--- a/archaeological_finds/templates/ishtar/sheet_basefind.html
+++ b/archaeological_finds/templates/ishtar/sheet_basefind.html
@@ -16,8 +16,8 @@
<div class='row'>
{% field_flex_detail "Operation" base_find.context_record.operation first %}
{% field_flex_detail "Archaeological site" base_find.context_record.archaeological_site first %}
- {% field_flex_detail "Context record" base_find.context_record first %}
- {% field_flex "Town" base_find.context_record.town.label_with_areas '' '' first %}
+ {% field_flex_detail "Context record" base_find.context_record.short_label first %}
+ {% field_flex "Town" base_find.context_record.town_label_with_areas '' '' first %}
{% field_flex "Parcel" base_find.context_record.parcel '' '' first %}
{# START discovery dates #}
@@ -48,6 +48,7 @@
{% with item=base_find %}
{% include "ishtar/blocks/sheet_json.html" %}
{% endwith %}
+ {% if not is_external %}
<h3>{% trans "Sheet"%}</h3>
<div class='row'>
{% with item.history_creation_date|date:"SHORT_DATETIME_FORMAT" as creation_date %}
@@ -62,6 +63,7 @@
{% endwith %}{% endwith %}
{% endif %}
</div>
+ {% endif %}
{% if base_find.point_2d or base_find.x or base_find.y or base_find.topographic_localisation %}
{% if base_find.point_2d %}
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index dd9c2e059..5b6c38112 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -11,7 +11,7 @@
{% if item.downstream_treatment %}
<div class="alert alert-warning" role="alert">
- {% trans "This sheet has a downstream treatment: it is related to an old version of the find." %}</p>
+ {% trans "This sheet has a downstream treatment: it is related to an old version of the find." %}
</div>
{% endif %}
@@ -19,14 +19,13 @@
{% with permission_view_document=permission_view_document %}
{% with permission_view_own_document=permission_view_own_document %}
-{% with m2m_listing_datings=item|m2m_listing:'datings' %}
{% with non_modif_treatments_count=item.non_modif_treatments_count %}
{% with associated_treatment_files_count=item.associated_treatment_files_count %}
-{% with display_datings=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|or_:m2m_listing_datings|or_:item.dating_comment|or_:item.cultural_attributions.count %}
+{% with display_datings=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|or_:item.m2m_listing_datings|or_:item.dating_comment|or_:item.cultural_attributions.count %}
{% with display_warehouse_treatments=item.container|or_:item.container_ref|or_:item.upstream_treatment|or_:item.downstream_treatment|or_:non_modif_treatments_count|or_:associated_treatment_files_count %}
{% with can_view_documents=permission_view_own_document|or_:permission_view_document %}
-{% with display_documents=can_view_documents|and_:item.documents.count %}
+{% with display_documents=can_view_documents|and_:item.documents_count %}
{% if output != "ODT" and output != "PDF"%}
<ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist">
@@ -87,7 +86,7 @@
<div class="tab-pane fade show active" id="{{window_id}}-basefind"
role="tabpanel" aria-labelledby="{{window_id}}-basefind-tab">
- {% with has_image=item.images.count %}
+ {% with has_image=item.images_number %}
{% if has_image %}
<div class="clearfix">
<div class="card float-left col-12 col-md-6 col-lg-4">
@@ -120,11 +119,19 @@
</ul>
<div class="tab-content">
+ {% if is_external %}
+ {% for base_find in item.base_finds_list %}
+ {% with first=forloop.first|add:has_image %}
+ {% include "ishtar/sheet_basefind.html" %}
+ {% endwith %}
+ {% endfor %}
+ {% else %}
{% for base_find in item.base_finds.all %}
{% with first=forloop.first|add:has_image %}
{% include "ishtar/sheet_basefind.html" %}
{% endwith %}
{% endfor %}
+ {% endif %}
</div>
{% if has_image %}
</div>
@@ -206,7 +213,7 @@
{% if display_datings %}
<div class="tab-pane fade" id="{{window_id}}-preservation"
role="tabpanel" aria-labelledby="{{window_id}}-preservation-tab">
- {% 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 %}
+ {% 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' %}
@@ -223,9 +230,9 @@
</div>
{% endif %}
- {% if m2m_listing_datings or item.dating_comment or item.cultural_attributions.count %}
+ {% if item.m2m_listing_datings or item.dating_comment or item.cultural_attributions_count %}
<h3>{% trans "Dating" %}</h3>
- {% if item.cultural_attributions.count %}
+ {% if item.cultural_attributions_count %}
<div class='row'>
{% field_flex_multiple_obj "Cultural attributions" item 'cultural_attributions' %}
</div>
@@ -239,7 +246,7 @@
<th>{% trans "Quality" %}</th>
<th>{% trans "Precise dating" %}</th>
</tr>
- {% for dating in m2m_listing_datings %}
+ {% for dating in item.m2m_listing_datings %}
<tr>
<td>
{{dating.period}}
@@ -285,6 +292,7 @@
<dd>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
+ {% if not is_external %}
{% for loca in item.container_ref.get_localisations %}
<li class="breadcrumb-item">
{{loca.short_label}}&nbsp;{{loca|simple_link_to_window}}
@@ -293,6 +301,9 @@
<li class="breadcrumb-item">
{{item.container_ref.short_label}}&nbsp;{{item.container_ref|simple_link_to_window}}
</li>
+ {% else %}
+ {{item.container_ref}}
+ {% endif %}
</ol>
</nav>
</dd>
@@ -309,6 +320,7 @@
<dd>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
+ {% if not is_external %}
{% for loca in item.container.get_localisations %}
<li class="breadcrumb-item">
{{loca.short_label}}&nbsp;{{loca|simple_link_to_window}}
@@ -317,6 +329,16 @@
<li class="breadcrumb-item">
{{item.container.short_label}}&nbsp;{{item.container|simple_link_to_window}}
</li>
+ {% else %}
+ {% for loca in item.container.localisation_list %}
+ <li class="breadcrumb-item">
+ {{loca}}
+ </li>
+ {% endfor %}
+ <li class="breadcrumb-item">
+ {{item.container.short_label}}
+ </li>
+ {% endif %}
</ol>
</nav>
</dd>
@@ -490,7 +512,12 @@
<div class="tab-pane fade" id="{{window_id}}-documents"
role="tabpanel" aria-labelledby="{{window_id}}-documents-tab">
{% trans "Associated documents" as finds_docs %}
+ {% if item.documents.count %}
{% dynamic_table_document finds_docs 'documents' 'finds' item.pk '' output %}
+ {% elif item.documents_list %}
+ <h3>{{finds_docs}}</h3>
+ {% include "ishtar/blocks/api_document_list.html" %}
+ {% endif %}
</div>
{% endif %}
{% if item.data and item.data|length > 0 %}
@@ -501,7 +528,7 @@
{% endif %}
</div>
-{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}
+{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}
{% endblock %}