[Django] #33679: "empty" suffix gets added to last (original) admin inline form row for readonly views

11 views
Skip to first unread message

Django

unread,
May 4, 2022, 5:51:52 AM5/4/22
to django-...@googlegroups.com
#33679: "empty" suffix gets added to last (original) admin inline form row for
readonly views
-----------------------------------------+------------------------
Reporter: Daniel Hahler | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
`django/contrib/admin/templates/admin/edit_inline/tabular.html` has the
following code:

{{{
<tr class="form-row {% if inline_admin_form.original or
inline_admin_form.show_url %}has_original{% endif %}{% if forloop.last and
inline_admin_formset.has_add_permission %} empty-form{% endif %}"
id="{{ inline_admin_formset.formset.prefix }}-{% if not
forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
}}}

The condition for adding the "empty" suffix to the id does not work when
the object is readonly (no `has_add_permission`).

I think it should use the same condition as with the handling of the
`empty-form` class.

The empty row gets added based on this in the first place:
https://github.com/django/django/blob/f97401d1b184406d2e24f11eddbdaca8bbc360e3/django/contrib/admin/helpers.py#L299-L304

ref (added in):
https://github.com/django/django/commit/825f0beda804e48e9197fcf3b0d909f9f548aa47
#diff-3bed8380f4461efe8e7ec596937f85def59b1e38dcd6edd6e7f76c7a45d53f02

--
Ticket URL: <https://code.djangoproject.com/ticket/33679>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 6, 2022, 2:17:04 AM5/6/22
to django-...@googlegroups.com
#33679: "empty" suffix gets added to last (original) admin inline form row for
readonly views
-------------------------------+-----------------------------------------
Reporter: Daniel Hahler | Owner: Daniel Hahler
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => Daniel Hahler
* status: new => assigned
* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Good catch!

[https://github.com/django/django/pull/15661 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/33679#comment:1>

Django

unread,
May 6, 2022, 2:42:24 AM5/6/22
to django-...@googlegroups.com
#33679: "empty" suffix gets added to last (original) admin inline form row for
readonly views
-------------------------------------+-------------------------------------

Reporter: Daniel Hahler | Owner: Daniel
| Hahler
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/33679#comment:2>

Django

unread,
May 6, 2022, 3:28:10 AM5/6/22
to django-...@googlegroups.com
#33679: "empty" suffix gets added to last (original) admin inline form row for
readonly views
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Daniel
| Hahler
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"dddc8bc47d20083c63aea4a7acf1777ce197ec8d" dddc8bc]:
{{{
#!CommitTicketReference repository=""
revision="dddc8bc47d20083c63aea4a7acf1777ce197ec8d"
Fixed #33679 -- Fixed the last inline's id in admin for users without add
permissions.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33679#comment:3>

Reply all
Reply to author
Forward
0 new messages