From c33ec9bff99e12aaed28c8ea3c46e391a1de37c1 Mon Sep 17 00:00:00 2001 From: imperosol Date: Fri, 6 Nov 2026 13:22:05 +0100 Subject: [PATCH] fix: hide warning that shouldn't be displayed --- counter/templates/counter/product_form.jinja | 18 ++++++++++-------- counter/views/admin.py | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/counter/templates/counter/product_form.jinja b/counter/templates/counter/product_form.jinja index c30b3e86..534ab223 100644 --- a/counter/templates/counter/product_form.jinja +++ b/counter/templates/counter/product_form.jinja @@ -83,15 +83,17 @@ {% endmacro %} {% block content %} -
-
- {%- trans trimmed -%} - You can see product details. - However, you cannot edit it, thus you won't be able - to submit this form. - {%- endtrans -%} + {% if not user.has_perm("counter.change_product") %} +
+
+ {%- trans trimmed -%} + You can see product details. + However, you cannot edit it, thus you won't be able + to submit this form. + {%- endtrans -%} +
-
+ {% endif %} {% if object %}

{{ object }}

{% trans %}Creation date{% endtrans %} : {{ object.created_at|date }}

diff --git a/counter/views/admin.py b/counter/views/admin.py index 6f5053d6..17277b14 100644 --- a/counter/views/admin.py +++ b/counter/views/admin.py @@ -181,6 +181,9 @@ class ProductEditView(CounterAdminTabsMixin, PermissionRequiredMixin, UpdateView permission_required = "counter.change_product" def has_permission(self): + # If users can see products but not edit them, + # still show them this form, as it is the place where all infos are, + # but forbid to save it. return self.request.user.has_perm("counter.change_product") or ( self.request.method == "GET" and self.request.user.has_perm("counter.view_product")