Fixed #27991 -- Added obj arg to InlineModelAdmin.has_add_permission().

Thanks Vladimir Ivanov for the initial patch.
This commit is contained in:
Jon Dufresne 2018-02-21 19:11:50 -08:00 committed by Tim Graham
parent 4f88143649
commit be6ca89396
7 changed files with 128 additions and 6 deletions

View file

@ -41,6 +41,9 @@ details on these changes.
* ``django.contrib.staticfiles.templatetags.static()`` will be removed.
* The shim to allow ``InlineModelAdmin.has_add_permission()`` to be defined
without an ``obj`` argument will be removed.
.. _deprecation-removed-in-2.1:
2.1

View file

@ -2395,10 +2395,15 @@ The ``InlineModelAdmin`` class adds or customizes:
inline forms. For example, this may be based on the model instance
(passed as the keyword argument ``obj``).
.. method:: InlineModelAdmin.has_add_permission(request)
.. method:: InlineModelAdmin.has_add_permission(request, obj)
Should return ``True`` if adding an inline object is permitted, ``False``
otherwise.
otherwise. ``obj`` is the parent object being edited or ``None`` when
adding a new parent.
.. versionchanged:: 2.1
The ``obj`` argument was added.
.. method:: InlineModelAdmin.has_change_permission(request, obj=None)

View file

@ -64,6 +64,9 @@ Minor features
with ``change_list_object_tools.html`` and
``change_form_object_tools.html`` templates.
* :meth:`.InlineModelAdmin.has_add_permission` is now passed the parent object
as the second positional argument, ``obj``.
:mod:`django.contrib.admindocs`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -398,6 +401,10 @@ Miscellaneous
* ``django.contrib.staticfiles.templatetags.static()`` is deprecated in favor
of ``django.templatetags.static.static()``.
* Support for :meth:`.InlineModelAdmin.has_add_permission` methods that don't
accept ``obj`` as the second positional argument will be removed in Django
3.0.
.. _removed-features-2.1:
Features removed in 2.1