summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-10-01 03:56:35 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:20 +0100
commitb32c94e91ba0195eab52f6ea4512845be94a3cba (patch)
tree2ad4db00c989723b0d6c4cb2662f35b349597be7
parentb4d3b7d7d8a994f636c16697f245ac14d7a3f547 (diff)
downloadIshtar-b32c94e91ba0195eab52f6ea4512845be94a3cba.tar.bz2
Ishtar-b32c94e91ba0195eab52f6ea4512845be94a3cba.zip
Sheet: document tab for container, warehouse and file
-rw-r--r--archaeological_files/templates/ishtar/sheet_file.html19
-rw-r--r--archaeological_warehouse/models.py9
-rw-r--r--archaeological_warehouse/templates/ishtar/sheet_container.html26
-rw-r--r--archaeological_warehouse/templates/ishtar/sheet_warehouse.html27
4 files changed, 71 insertions, 10 deletions
diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html
index 989c2cdfd..58a8e5a78 100644
--- a/archaeological_files/templates/ishtar/sheet_file.html
+++ b/archaeological_files/templates/ishtar/sheet_file.html
@@ -1,5 +1,5 @@
{% extends "ishtar/sheet.html" %}
-{% load i18n window_ope_tables window_field window_header %}
+{% load i18n ishtar_helpers window_ope_tables window_field window_header window_tables %}
{% block head_title %}<strong>{% trans "Archaeological file" %}</strong> - {{item.full_internal_ref|default:''}}{% endblock %}
@@ -13,18 +13,21 @@
{% 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 %}
<div class="row">
<div class="offset-lg-4 col-lg-4 offset-md-3 col-md-6 offset-sm-1 col-sm-10 col-12">
<div class="card">
{% include "ishtar/blocks/window_image.html" %}
<div class="card-body">
- <p class="card-text">
+ <div class="card-text">
<p class='window-refs'>{{item.full_internal_ref|default:''}}</p>
<p class='window-refs'>{{item.internal_reference|default:''}}</p>
<p class='window-refs'>{{item.name|default:''}}</p>
{% include "ishtar/blocks/sheet_external_id.html" %}
- </p>
+ </div>
</div>
</div>
</div>
@@ -206,4 +209,14 @@
</table>
{% endif %}
+
+{% trans "Document for this archaeological file" as fle_docs %}
+{% if permission_view_own_document or permission_view_document %}
+{% if item.documents.count %}
+{% dynamic_table_document fle_docs 'documents' 'files' item.pk '' output %}
+{% endif %}
+{% endif %}
+
+
+{% endwith %} {% endwith %} {% endwith %}
{% endblock %}
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 %}<strong>{% trans "Container" %}</strong> -
{{ 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"%}
<ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist">
@@ -34,6 +37,15 @@
{% trans "Statistics" %}
</a>
</li>
+ {% if display_documents %}
+ <li class="nav-item">
+ <a class="nav-link" id="{{window_id}}-documents-tab"
+ data-toggle="tab" href="#{{window_id}}-documents" role="tab"
+ aria-controls="{{window_id}}-documents" aria-selected="false">
+ {% trans "Documents" %}
+ </a>
+ </li>
+ {% endif %}
</ul>
{% endif %}
@@ -230,6 +242,17 @@
{% endif %}
{% endif %}
</div>
+ {% if display_documents %}
+ <div class="tab-pane fade" id="{{window_id}}-documents"
+ role="tabpanel" aria-labelledby="{{window_id}}-documents-tab">
+ {% 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 %}
+ </div>
+ {% endif %}
</div>
@@ -250,4 +273,5 @@ $(document).ready( function () {
} );
</script>
+{% 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 %}<strong>{% trans "Warehouse" %}</strong> - {{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"%}
<ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist">
@@ -32,6 +34,15 @@
{% trans "Statistics" %}
</a>
</li>
+ {% if display_documents %}
+ <li class="nav-item">
+ <a class="nav-link" id="{{window_id}}-documents-tab"
+ data-toggle="tab" href="#{{window_id}}-documents" role="tab"
+ aria-controls="{{window_id}}-documents" aria-selected="false">
+ {% trans "Documents" %}
+ </a>
+ </li>
+ {% endif %}
</ul>
{% endif %}
@@ -214,6 +225,17 @@
{% endif %}
</div>
+ {% if display_documents %}
+ <div class="tab-pane fade" id="{{window_id}}-documents"
+ role="tabpanel" aria-labelledby="{{window_id}}-documents-tab">
+ {% 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 %}
+ </div>
+ {% endif %}
</div>
<script type="text/javascript">
@@ -233,4 +255,5 @@ $(document).ready( function () {
} );
</script>
+{% endwith %} {% endwith %} {% endwith %}
{% endblock %}