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.
* 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>
* 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>
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>
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>
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>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27942#comment:6>
* 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>