#32405: Inline admin - last related item also hidden when user has no
add_permission
----------------------------------+--------------------------------------
     Reporter:  Pirmin Schneider  |                    Owner:  nobody
         Type:  Bug               |                   Status:  new
    Component:  contrib.admin     |                  Version:  3.1
     Severity:  Normal            |               Resolution:
     Keywords:  inline admin      |             Triage Stage:  Unreviewed
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------
Description changed by Pirmin Schneider:

Old description:

> Reproduce:
> * Create a TabularInline admin
> * add
>
> {{{
>
> def has_add_permission(self, request, obj=None):
>     return False
> }}}
>
> Observed behavior:
> The add-button disappears, and the last item of the related inline items
> disappears.
>
> Expected behavior:
> Only the add-button disappears
>
> For some reason the `empty-form` class is added multiple times. Once
> (correctly) to the `add-row` and once to the last `form-row` (while the
> `add-row` is in fact the last row of the table in the DOM)
>
> This LOC in `django/contrib/admin/tabular.html` seems relevant, although
> i cannot see the issue there
>
> ```
> % if forloop.last and inline_admin_formset.has_add_permission %} empty-
> form{% endif %}
> ```

New description:

 Reproduce:
 * Create a TabularInline admin
 * add

 {{{

 def has_add_permission(self, request, obj=None):
     return False
 }}}

 Observed behavior:
 The add-button disappears, and the last item of the related inline items
 disappears.

 Expected behavior:
 Only the add-button disappears

 For some reason the `empty-form` class is added multiple times. Once
 (correctly) to the `add-row` and once to the last `form-row` (while the
 `add-row` is in fact the last row of the table in the DOM)

 This LOC in `django/contrib/admin/tabular.html` seems relevant, although i
 cannot see the issue there

 {{{
 % if forloop.last and inline_admin_formset.has_add_permission %} empty-
 form{% endif %}
 }}}

--

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.afebe2e9bd246c2db408c558c31e698a%40djangoproject.com.

Reply via email to