From ce71f7f286819ee1399fef5f1819f9cc812149a6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 13 Mar 2025 13:30:02 +0100 Subject: ✨ sheets: refactor document listing - add edit and unlink actions (refs #6221) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_finds/models_treatments.py | 5 ++--- .../templates/ishtar/sheet_exhibition.html | 5 +++-- archaeological_finds/templates/ishtar/sheet_find.html | 10 +++------- .../templates/ishtar/sheet_museum_find.html | 10 +++------- .../templates/ishtar/sheet_treatment.html | 19 +++++++++++++------ .../templates/ishtar/sheet_treatmentfile.html | 5 +++-- 6 files changed, 27 insertions(+), 27 deletions(-) (limited to 'archaeological_finds') diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 0c684d98a..69a8b899c 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -196,14 +196,13 @@ class AssociatedFindBasket: class Treatment( DashboardFormItem, AssociatedFindBasket, - ValueGetter, DocumentItem, BaseHistorizedItem, CompleteIdentifierItem, ImageModel, OwnPerms, - ShortMenuItem, - SheetItem, + ValueGetter, + MainItem, ): SLUG = "treatment" APP = "archaeological-finds" diff --git a/archaeological_finds/templates/ishtar/sheet_exhibition.html b/archaeological_finds/templates/ishtar/sheet_exhibition.html index 820391a9e..76cf7c495 100644 --- a/archaeological_finds/templates/ishtar/sheet_exhibition.html +++ b/archaeological_finds/templates/ishtar/sheet_exhibition.html @@ -78,8 +78,9 @@ {% if display_documents %} - {% trans "Associated documents" as associated_docs %} - {% dynamic_table_document associated_docs 'documents' 'treatment_files' item.pk '' output %} + {% with permission_change_item=item|can_edit_item:request %} + {% include "ishtar/blocks/sheet_document_list.html" %} + {% endwith %} {% endif %} {% if item.administrative_act.count %} diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index d38b0060f..9b439825c 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -280,13 +280,9 @@ {% if display_documents %}
- {% trans "Associated documents" as finds_docs %} - {% if item.documents.count %} - {% dynamic_table_document finds_docs 'documents' 'finds' item.pk '' output %} - {% elif item.documents_list %} -

{{finds_docs}}

- {% include "ishtar/blocks/api_document_list.html" %} - {% endif %} + {% with permission_change_item=item|can_edit_item:request %} + {% include "ishtar/blocks/sheet_document_list.html" %} + {% endwith %}
{% endif %} diff --git a/archaeological_finds/templates/ishtar/sheet_museum_find.html b/archaeological_finds/templates/ishtar/sheet_museum_find.html index 2f313f0a1..fb5e2adca 100644 --- a/archaeological_finds/templates/ishtar/sheet_museum_find.html +++ b/archaeological_finds/templates/ishtar/sheet_museum_find.html @@ -304,13 +304,9 @@ {% if display_documents %}
- {% trans "Associated documents" as finds_docs %} - {% if item.documents.count %} - {% dynamic_table_document finds_docs 'documents' 'finds' item.pk '' output %} - {% elif item.documents_list %} -

{{finds_docs}}

- {% include "ishtar/blocks/api_document_list.html" %} - {% endif %} + {% with permission_change_item=item|can_edit_item:request %} + {% include "ishtar/blocks/sheet_document_list.html" %} + {% endwith %}
{% endif %} diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html index 7fa2097f0..ae180dd5e 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatment.html +++ b/archaeological_finds/templates/ishtar/sheet_treatment.html @@ -1,5 +1,5 @@ {% extends "ishtar/sheet.html" %} -{% load i18n l10n window_field from_dict link_to_window window_tables window_ope_tables window_header humanize %} +{% load i18n l10n ishtar_helpers window_field from_dict link_to_window window_tables window_ope_tables window_header humanize %} {% block head_title %}{% trans "Treatment" %} - {{ item.cached_label|default:"" }}{% endblock %} @@ -8,6 +8,12 @@ {% endblock %} {% block content %} +{# trick to set to null non existing variable #} +{% with permission_view_document=permission_view_document %} +{% with permission_view_own_document=permission_view_own_document %} +{% with can_view_documents=permission_view_own_document|or_:permission_view_document %} +{% with has_documents=item|safe_or:"documents.count|documents_list"|safe_and_not:"documents_not_available" %} +{% with display_documents=can_view_documents|and_:has_documents %}