Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add permission check for "Add another" buttons #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h3 class="djn-collapse-handler grp-collapse-handler{% if not inline_opts.sortab
{% endfor %}
{% endwith %}
</div>
{% if inline_admin_formset.has_add_permission %}
<div class="grp-module djn-module djn-add-item grp-transparent">
<div class="grp-row">
<a href="javascript://" class="djn-add-handler grp-add-handler {{ inline_admin_formset.handler_classes|join:" " }}">
Expand All @@ -98,6 +99,7 @@ <h3 class="djn-collapse-handler grp-collapse-handler{% if not inline_opts.sortab
</ul>
</div>
</div>
{% endif %}
</div>
{% endwith %}{# ends with inline_admin_formset.opts as inline_opts #}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ <h3 style="display: none;"><b>{{ inline_admin_formset.opts.verbose_name }} #{{ f

</table>

{% if inline_admin_formset.has_add_permission %}
<div class="grp-module grp-transparent">
<div class="grp-row djn-add-item">
<a href="javascript://" class="djn-add-handler grp-add-handler {{ inline_admin_formset.handler_classes|join:" " }}"><strong>{% blocktrans with inline_admin_formset.opts.verbose_name|strip_parent_name:inline_opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}</strong></a>
Expand All @@ -84,6 +85,7 @@ <h3 style="display: none;"><b>{{ inline_admin_formset.opts.verbose_name }} #{{ f
</ul>
</div>
</div>
{% endif %}
</div>
{% endwith %}{# ends with inline_admin_formset.opts as inline_opts #}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ <h3 class="djn-collapse-handler grp-collapse-handler{% if not inline_opts.sortab
{% endfor %}
{% endwith %}
</div>
{% if inline_admin_formset.has_add_permission %}
<div class="grp-module djn-module djn-add-item grp-transparent">
<div class="grp-row polymorphic-add-choice">
<a href="javascript://" class="djn-add-handler grp-add-handler {{ inline_admin_formset.handler_classes|join:" " }}">
Expand All @@ -95,6 +96,7 @@ <h3 class="djn-collapse-handler grp-collapse-handler{% if not inline_opts.sortab
</ul>
</div>
</div>
{% endif %}
</div>
{% endwith %}{# ends with inline_admin_formset.opts as inline_opts #}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h2>
data-is-initial="{% if inline_admin_form.pk_field.field.value %}true{% else %}false{% endif %}"
{% endif %}
id="{{ inline_admin_formset.formset.prefix }}-{% if not inline_admin_form.is_empty %}{{ inline_admin_form.form|form_index }}{% else %}empty-{{ inline_admin_form.model_admin.opts.app_label }}-{{ inline_admin_form.model_admin.opts.model_name }}{% endif %}">

<h3 class="{% if not inline_opts.sortable_options or not inline_opts.sortable_options.disabled %} djn-drag-handler{% endif %}">
<b>{{ inline_admin_form.model_admin.opts.verbose_name|capfirst }}:</b>&nbsp;<span class="inline_label">{% 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 %} <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink">{% trans "Change" %}</a>{% endif %}
{% else %}#{{ forloop.counter }}{% endif %}</span>
Expand Down Expand Up @@ -69,11 +69,13 @@ <h3 class="{% if not inline_opts.sortable_options or not inline_opts.sortable_op
{% endfor %}
{% endwith %}
</div>
{% if inline_admin_formset.has_add_permission %}
<div class="djn-module djn-add-item add-item add-row polymorphic-add-choice">
<a href="javascript://" class="add-handler djn-add-handler {{ inline_admin_formset.handler_classes|join:" " }}">
{% blocktrans with inline_admin_formset.opts.verbose_name|strip_parent_name:inline_opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}
</a>
</div>
{% endif %}
{% ifinlineclasses %}</fieldset>{% endifinlineclasses %}
</div>
{% endwith %}{# ends with inline_admin_formset.opts as inline_opts #}
Expand Down
4 changes: 3 additions & 1 deletion nested_admin/templates/nesting/admin/inlines/stacked.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h2>
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 %}">

<h3 class="{% if not inline_opts.sortable_options or not inline_opts.sortable_options.disabled %} djn-drag-handler{% endif %}">
<b>{{ inline_admin_formset.opts.verbose_name|capfirst }}:</b>&nbsp;<span class="inline_label">{% 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 %} <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="{% if inline_admin_formset.has_change_permission %}inlinechangelink{% else %}inlineviewlink{% endif %}">{% if inline_admin_formset.has_change_permission %}{% trans "Change" %}{% else %}{% trans "View" %}{% endif %}</a>{% endif %}
{% else %}#{{ forloop.counter }}{% endif %}</span>
Expand Down Expand Up @@ -66,11 +66,13 @@ <h3 class="{% if not inline_opts.sortable_options or not inline_opts.sortable_op
{% endfor %}
{% endwith %}
</div>
{% if inline_admin_formset.has_add_permission %}
<div class="djn-module djn-add-item add-item add-row">
<a href="javascript://" class="add-handler djn-add-handler {{ inline_admin_formset.handler_classes|join:" " }}">
{% blocktrans with inline_admin_formset.opts.verbose_name|strip_parent_name:inline_opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}
</a>
</div>
{% endif %}
{% ifinlineclasses %}</fieldset>{% endifinlineclasses %}
</div>
{% endwith %}{# ends with inline_admin_formset.opts as inline_opts #}
Expand Down