make formula deletion page clearer

This commit is contained in:
imperosol
2026-02-10 16:00:15 +01:00
parent ac663473c3
commit 72e0aa24a5
3 changed files with 30 additions and 1 deletions

View File

@@ -21,6 +21,8 @@
<h2>{% trans %}Delete confirmation{% endtrans %}</h2>
<form action="" method="post">{% csrf_token %}
<p>{% trans name=object_name %}Are you sure you want to delete "{{ name }}"?{% endtrans %}</p>
{% if help_text %}<p><em>{{ help_text }}</em></p>{% endif %}
<br/>
<input type="submit" value="{% trans %}Confirm{% endtrans %}" />
</form>
<form method="GET" action="javascript:history.back();">

View File

@@ -166,7 +166,9 @@ class ProductEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
class ProductFormulaListView(CounterAdminTabsMixin, PermissionRequiredMixin, ListView):
model = ProductFormula
queryset = ProductFormula.objects.select_related("result")
queryset = ProductFormula.objects.select_related("result").prefetch_related(
"products"
)
template_name = "counter/formula_list.jinja"
current_tab = "formulas"
permission_required = "counter.view_productformula"
@@ -206,6 +208,17 @@ class ProductFormulaDeleteView(
success_url = reverse_lazy("counter:product_formula_list")
permission_required = "counter.delete_productformula"
def get_context_data(self, **kwargs):
obj_name = self.object.result.name
return super().get_context_data(**kwargs) | {
"object_name": _("%(formula)s (formula)") % {"formula": obj_name},
"help_text": _(
"This action will only delete the formula, "
"but not the %(product)s product itself."
)
% {"product": obj_name},
}
class ReturnableProductListView(
CounterAdminTabsMixin, PermissionRequiredMixin, ListView

View File

@@ -3843,6 +3843,20 @@ msgstr "Temps"
msgid "Top 100 barman %(counter_name)s (all semesters)"
msgstr "Top 100 barman %(counter_name)s (tous les semestres)"
#: counter/views/admin.py
#, python-format
msgid "%(formula)s (formula)"
msgstr "%(formula)s (formule)"
#: counter/views/admin.py
#, python-format
msgid ""
"This action will only delete the formula, but not the %(product)s product "
"itself."
msgstr ""
"Cette action supprimera seulement la formule, mais pas le produit "
"%(product)s en lui-même."
#: counter/views/admin.py
#, python-format
msgid "returnable product : %(returnable)s -> %(returned)s"