[Django] #27942: Admin Issue with Tables in Custom Field in Tabular Inlines

44 views
Skip to first unread message

Django

unread,
Mar 15, 2017, 3:30:35 AM3/15/17
to django-...@googlegroups.com
#27942: Admin Issue with Tables in Custom Field in Tabular Inlines
-----------------------------------------+------------------------
Reporter: James Pulec | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-----------------------------------------+------------------------
It seems that there are issues using tabular inlines, if you're using a
custom field that is rendered with a table.

For example, if you have some custom field like [https://github.com
/django-recurrence/django-recurrence] uses and try to use it in a tabular
inline, the result will be that there is an extra add button appended
inside the custom field widget.

This seems to be caused by
https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/inlines.js#L23
since it tries to fetch the parent by using the selector defined on by
`this`, which simply selects ANY child table rows of the current inline
form. It's this selector that is then later used to determine where to
append the add buttons, and if `$parent` selector has multiple results,
add buttons get appended to all of them.

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

Django

unread,
Mar 15, 2017, 8:56:35 AM3/15/17
to django-...@googlegroups.com
#27942: admin's inlines.js indiscriminately adds "add" buttons to all tables in
inlines
-------------------------------+------------------------------------

Reporter: James Pulec | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

* stage: Unreviewed => Accepted


Comment:

I haven't tried to reproduce this but the idea seems reasonable.

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

Django

unread,
Mar 24, 2017, 11:34:53 AM3/24/17
to django-...@googlegroups.com
#27942: admin's inlines.js indiscriminately adds "add" buttons to all tables in
inlines
-------------------------------------+-------------------------------------
Reporter: James Pulec | Owner: Adonys
| Alea Boffill
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Adonys Alea Boffill):

* owner: nobody => Adonys Alea Boffill
* status: new => assigned


Comment:

I reached to reproduce the issue, I'm working to propose a solution.

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

Django

unread,
Mar 24, 2017, 4:23:15 PM3/24/17
to django-...@googlegroups.com
#27942: admin's inlines.js indiscriminately adds "add" buttons to all tables in
inlines
-------------------------------------+-------------------------------------
Reporter: James Pulec | Owner: Adonys
| Alea Boffill
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Adonys Alea Boffill):

I have a solution modifying the jQuery selector we can change:
{{{
$(inlineOptions.name + "-group .tabular.inline-related tbody tr")
}}}
by
{{{
$(inlineOptions.name + "-group .tabular.inline-related tbody:first > tr")
}}}

That solution works good, all test are passed.

But the interesting thing is... what is the best option to build tests to
satisfy this fixed??? This is an scenario difficult to reproduce.
* JavaScript tests
* Selenium tests
* Both

To build selenium tests I think that is necessary to implement some test
widget in order to generate the HTML content necessary to reproduce the
specific scenario.

some other idea before start to try to build the tests??

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

Django

unread,
Mar 24, 2017, 7:58:45 PM3/24/17
to django-...@googlegroups.com
#27942: admin's inlines.js indiscriminately adds "add" buttons to all tables in
inlines
-------------------------------------+-------------------------------------
Reporter: James Pulec | Owner: Adonys
| Alea Boffill
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

I think it'd be acceptable to merge this fix without a test.

--
Ticket URL: <https://code.djangoproject.com/ticket/27942#comment:4>

Django

unread,
Mar 27, 2017, 11:19:34 AM3/27/17
to django-...@googlegroups.com
#27942: admin's inlines.js indiscriminately adds "add" buttons to all tables in
inlines
-------------------------------------+-------------------------------------
Reporter: James Pulec | Owner: Adonys
| Alea Boffill
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Adonys Alea Boffill):

Thanks Tim!, I added the PR https://github.com/django/django/pull/8256

--
Ticket URL: <https://code.djangoproject.com/ticket/27942#comment:5>

Django

unread,
Mar 27, 2017, 12:29:07 PM3/27/17
to django-...@googlegroups.com
#27942: admin's inlines.js indiscriminately adds "add" buttons to all tables in
inlines
-------------------------------------+-------------------------------------
Reporter: James Pulec | Owner: Adonys
| Alea Boffill
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
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: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27942#comment:6>

Django

unread,
Mar 30, 2017, 10:40:08 AM3/30/17
to django-...@googlegroups.com
#27942: admin's inlines.js indiscriminately adds "add" buttons to all tables in
inlines
-------------------------------------+-------------------------------------
Reporter: James Pulec | Owner: Adonys
| Alea Boffill
Type: Bug | Status: closed
Component: contrib.admin | Version: master
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: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"a0d29a9abe93cbe87cf818c3b538506e49739b6c" a0d29a9]:
{{{
#!CommitTicketReference repository=""
revision="a0d29a9abe93cbe87cf818c3b538506e49739b6c"
Fixed #27942 -- Prevented admin from adding "add" buttons to all tables in
inlines.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27942#comment:7>

Reply all
Reply to author
Forward
0 new messages