summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-05-23 16:01:37 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-05-23 16:01:37 +0200
commit465cd1aad9b091d18f4c9a208d0c091bf14f6dc0 (patch)
tree7bd90772d24bce714f539d097a7b0bd552639f2c
parentb3a500de8a495f0b5e63647887d0113f7c556e2e (diff)
downloadIshtar-465cd1aad9b091d18f4c9a208d0c091bf14f6dc0.tar.bz2
Ishtar-465cd1aad9b091d18f4c9a208d0c091bf14f6dc0.zip
Find sheet: display associated treatment files
-rw-r--r--archaeological_finds/models_finds.py10
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html39
2 files changed, 47 insertions, 2 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index e62c41887..5bffe9851 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -1741,6 +1741,16 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, QRCodeItem,
def limited_non_modif_treatments(self):
return self.non_modif_treatments(15)
+ def associated_treatment_files(self):
+ from archaeological_finds.models_treatments import \
+ TreatmentFile
+ return TreatmentFile.objects.filter(
+ associated_basket__items__pk=self.pk).order_by(
+ 'reception_date', 'creation_date', 'end_date')
+
+ def associated_treatment_files_count(self):
+ return self.associated_treatment_files().count()
+
@property
def weight_string(self):
if not self.weight:
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index 7644acb60..268a31d39 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -21,9 +21,10 @@
{% 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 %}
-{% with display_warehouse_treatments=item.container|or_:item.container_ref|or_:item.upstream_treatment|or_:item.downstream_treatment|or_:non_modif_treatments_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 %}
@@ -381,6 +382,40 @@
<p class='tool'><a class='badge' href="{% url 'get-downstreamtreatment' 'csv' %}?submited=1&amp;find_id={{item.pk}}" target="_blank">{% trans "CSV" %}</a> ({{ENCODING}})</p>
{% endif %}
{% endif %}
+ {% if item.associated_treatment_files_count %}
+ <h3>{% trans "Treatment requests" %}</h3>
+ <table id='{{window_id}}-treatment-files' class="table table-striped">
+ <tr>
+ <th>&nbsp;</th>
+ <th>{% trans "Year - index" %}</th>
+ <th>{% trans "Type" %}</th>
+ <th>{% trans "Name" %}</th>
+ <th>{% trans "Person in charge" %}</th>
+ <th>{% trans "Applicant" %}</th>
+ <th>{% trans "Applicant organisation" %}</th>
+ <th>{% trans "Reception date" %}</th>
+ <th>{% trans "End date" %}</th>
+ </tr>
+ {% for treatment_file in item.associated_treatment_files %}
+ <tr>
+ <td>
+ <a class="display_details" href="#"
+ onclick="load_window('{% url 'show-treatmentfile' treatment_file.id %}/');">
+ <i class="fa fa-info-circle" aria-hidden="true"></i>
+ </a>
+ </td>
+ <td class='string'>{{ treatment_file.year }} - {{treatment_file.index}}</td>
+ <td class='string'>{{ treatment_file.type }}</td>
+ <td class='string'>{{ treatment_file.name|default_if_none:"-" }}</td>
+ <td class='string'>{{ treatment_file.in_charge|default_if_none:"" }}</td>
+ <td class='string'>{{ treatment_file.applicant|default_if_none:"" }}</td>
+ <td class='string'>{{ treatment_file.applicant_organisation|default_if_none:"" }}</td>
+ <td class='string'>{{ treatment_file.reception_date|default_if_none:"" }}</td>
+ <td class='string'>{{ treatment_file.end_date|default_if_none:"" }}</td>
+ </tr>
+ {% endfor %}
+ </table>
+ {% endif %}
</div>
{% endif %}
{% if display_documents %}
@@ -398,7 +433,7 @@
{% endif %}
</div>
-{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}
+{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}
{% endblock %}