From 7c1492353bf66ade8c446d2070708e35a05b42e0 Mon Sep 17 00:00:00 2001 From: Anikin Vasiliy Date: Fri, 20 Nov 2020 12:27:45 +0300 Subject: [PATCH] Add permission check for add buttons --- .../templates/nesting/admin/inlines/grappelli_stacked.html | 2 ++ .../templates/nesting/admin/inlines/grappelli_tabular.html | 2 ++ .../nesting/admin/inlines/polymorphic_grappelli_stacked.html | 2 ++ .../templates/nesting/admin/inlines/polymorphic_stacked.html | 4 +++- nested_admin/templates/nesting/admin/inlines/stacked.html | 4 +++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nested_admin/templates/nesting/admin/inlines/grappelli_stacked.html b/nested_admin/templates/nesting/admin/inlines/grappelli_stacked.html index c17da5c..c50b05c 100644 --- a/nested_admin/templates/nesting/admin/inlines/grappelli_stacked.html +++ b/nested_admin/templates/nesting/admin/inlines/grappelli_stacked.html @@ -86,6 +86,7 @@

{% endwith %}{# ends with inline_admin_formset.opts as inline_opts #} diff --git a/nested_admin/templates/nesting/admin/inlines/polymorphic_grappelli_stacked.html b/nested_admin/templates/nesting/admin/inlines/polymorphic_grappelli_stacked.html index f7416bc..34d5d1b 100644 --- a/nested_admin/templates/nesting/admin/inlines/polymorphic_grappelli_stacked.html +++ b/nested_admin/templates/nesting/admin/inlines/polymorphic_grappelli_stacked.html @@ -83,6 +83,7 @@

+ {% endif %} {% ifinlineclasses %}{% endifinlineclasses %} {% endwith %}{# ends with inline_admin_formset.opts as inline_opts #} diff --git a/nested_admin/templates/nesting/admin/inlines/stacked.html b/nested_admin/templates/nesting/admin/inlines/stacked.html index 907809e..5315033 100644 --- a/nested_admin/templates/nesting/admin/inlines/stacked.html +++ b/nested_admin/templates/nesting/admin/inlines/stacked.html @@ -29,7 +29,7 @@

data-is-initial="{% if inline_admin_form.pk_field.field.value %}true{% else %}false{% endif %}" {% endif %} id="{{ inline_admin_formset.formset.prefix }}-{% if forloop.last and inline_admin_formset.has_add_permission %}empty{% elif not forloop.last %}{{ inline_admin_form.form|form_index }}{% endif %}"> - +

{{ inline_admin_formset.opts.verbose_name|capfirst }}: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} {% if inline_admin_formset.has_change_permission %}{% trans "Change" %}{% else %}{% trans "View" %}{% endif %}{% endif %} {% else %}#{{ forloop.counter }}{% endif %} @@ -66,11 +66,13 @@

{% blocktrans with inline_admin_formset.opts.verbose_name|strip_parent_name:inline_opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %} + {% endif %} {% ifinlineclasses %}{% endifinlineclasses %} {% endwith %}{# ends with inline_admin_formset.opts as inline_opts #}