From b99ac628eab47ee9b047999ed30d5dcb074e8a57 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 1 Oct 2020 03:56:35 +0200 Subject: Sheet: document tab for container, warehouse and file --- archaeological_warehouse/models.py | 9 ++++---- .../templates/ishtar/sheet_container.html | 26 ++++++++++++++++++++- .../templates/ishtar/sheet_warehouse.html | 27 ++++++++++++++++++++-- 3 files changed, 55 insertions(+), 7 deletions(-) (limited to 'archaeological_warehouse') diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index f89092dba..b32d608af 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1290,13 +1290,14 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem, q = Container.objects if q.count(): self.index = int( - q.aggregate(Max("index"))["index__max"] or 0) + 1 + q.all().aggregate(Max("index"))["index__max"] or 0) + 1 else: self.index = 1 - elif self.responsible_id: # default is index by warehouse - q = Container.objects.filter(responsible=self.responsible) + else: # default is index by warehouse + q = Container.objects.filter(location=self.location) if q.count(): - self.index = int(q.aggregate(Max("index"))["index__max"]) + 1 + self.index = int( + q.all().aggregate(Max("index"))["index__max"]) + 1 else: self.index = 1 diff --git a/archaeological_warehouse/templates/ishtar/sheet_container.html b/archaeological_warehouse/templates/ishtar/sheet_container.html index 7ca39645d..238ab1e0c 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_container.html +++ b/archaeological_warehouse/templates/ishtar/sheet_container.html @@ -1,5 +1,5 @@ {% extends "ishtar/sheet.html" %} -{% load i18n window_header window_field window_tables link_to_window %} +{% load i18n ishtar_helpers window_header window_field window_tables link_to_window %} {% block head_title %}{% trans "Container" %} - {{ item.reference|default:"" }} ({{ item.container_type|default:"" }}) - {{item.location}} @@ -10,6 +10,9 @@ {% endblock %} {% block content %} +{% with can_view_documents=permission_view_own_document|or_:permission_view_document %} +{% with has_documents=item.documents.count %} +{% with display_documents=can_view_documents|and_:has_documents %} {% if output != "ODT" and output != "PDF"%} {% endif %} @@ -230,6 +242,17 @@ {% endif %} {% endif %} + {% if display_documents %} +
+ {% trans "Document for this container" as ct_docs %} + {% if permission_view_own_document or permission_view_document %} + {% if item.documents.count %} + {% dynamic_table_document ct_docs 'documents' 'containers' item.pk '' output %} + {% endif %} + {% endif %} +
+ {% endif %} @@ -250,4 +273,5 @@ $(document).ready( function () { } ); +{% endwith %} {% endwith %} {% endwith %} {% endblock %} diff --git a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html index b4786de5b..7c279fe69 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html +++ b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html @@ -1,5 +1,5 @@ {% extends "ishtar/sheet.html" %} -{% load i18n window_header window_field window_tables %} +{% load i18n ishtar_helpers window_header window_field window_tables %} {% block head_title %}{% trans "Warehouse" %} - {{item.name}} ({{item.warehouse_type}}){% endblock %} {% block toolbar %} @@ -7,7 +7,9 @@ {% endblock %} {% block content %} - +{% with can_view_documents=permission_view_own_document|or_:permission_view_document %} +{% with has_documents=item.documents.count %} +{% with display_documents=can_view_documents|and_:has_documents %} {% if output != "ODT" and output != "PDF"%} {% endif %} @@ -214,6 +225,17 @@ {% endif %} + {% if display_documents %} +
+ {% trans "Document for this warehouse" as w_docs %} + {% if permission_view_own_document or permission_view_document %} + {% if item.documents.count %} + {% dynamic_table_document w_docs 'documents' 'warehouses' item.pk '' output %} + {% endif %} + {% endif %} +
+ {% endif %} +{% endwith %} {% endwith %} {% endwith %} {% endblock %} -- cgit v1.2.3