From 0dac9c341be56b382fb6d5b918997aa2f41995ad Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 3 Apr 2023 17:53:01 +0200 Subject: Image detail: do not display Modify link when not relevant (refs #5438) --- CHANGES.md | 1 + ishtar_common/templates/ishtar/blocks/window_image.html | 8 +++++++- ishtar_common/views_item.py | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 28724550c..2ccc2d3ba 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Ishtar changelog - Sheets: fix history view with associated geo - Containers: remove division search - Importer export: fix pre_importer call +- Image detail: do not display Modify link when not relevant (refs #5438) v4.0.43 - 2023-03-17 -------------------- diff --git a/ishtar_common/templates/ishtar/blocks/window_image.html b/ishtar_common/templates/ishtar/blocks/window_image.html index 409ad25fa..376093171 100644 --- a/ishtar_common/templates/ishtar/blocks/window_image.html +++ b/ishtar_common/templates/ishtar/blocks/window_image.html @@ -1,16 +1,19 @@ -{% load i18n link_to_window %}{% if item.images_number %} +{% load i18n ishtar_helpers link_to_window %}{% if item.images_number %} {% if output == "ODT" or output == "PDF"%} {% include "ishtar/blocks/window_image_odt.html" %} {% else %} +{% with can_edit_document=permission_change_own_document|or_:permission_change_document %} {% trans "Sheet" as sheet_lbl %}
{% if item.main_image and item.main_image.image %}{% with image=item.main_image %}
× {{image|simple_link_to_window:sheet_lbl}}   + {% if can_edit_document %} {% trans "Modify" %} + {% endif %}
{% endwith %}{% endif %} {% for image in item.images_without_main_image.all %}{% if image.image %} @@ -18,9 +21,11 @@ × {% include "ishtar/blocks/window_image_detail.html" %} {{image|simple_link_to_window:sheet_lbl}}   + {% if can_edit_document %} {% trans "Modify" %} + {% endif %}
{% endif %}{% endfor %} @@ -38,5 +43,6 @@ {% endif %}{% endfor %} +{% endwith %} {% endif%} {% endif%} diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index a4ebd170c..5947a6798 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -377,6 +377,8 @@ def show_item(model, name, extra_dct=None, model_for_perms=None): for perm in Permission.objects.filter( codename__startswith='view_').values_list("codename", flat=True).all(): dct["permission_" + perm] = False + dct["permission_change_own_document"] = False + dct["permission_change_document"] = False if hasattr(request.user, "ishtaruser") and request.user.ishtaruser: cache_key = "{}-{}-{}".format( settings.PROJECT_SLUG, -- cgit v1.2.3