New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #27991 -- Add 'obj' kwarg to InlineModelAdmin.has_add_permission() #8304
Conversation
32e5d35
to
955cbf6
Compare
@@ -2220,6 +2217,21 @@ The ``InlineModelAdmin`` class adds: | |||
inline forms. For example, this may be based on the model instance | |||
(passed as the keyword argument ``obj``). | |||
|
|||
.. method:: InlineModelAdmin.has_add_permission(self, request, obj=None) | |||
|
|||
The ``has_add_permission`` method is given the HttpRequest and the parent ``obj``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap documentation at 79 characters.
django/contrib/admin/options.py
Outdated
inline.has_change_permission(request, obj) or | ||
inline.has_delete_permission(request, obj)): | ||
continue | ||
if not inline.has_add_permission(request): | ||
if not inline.has_add_permission(request, obj): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the ticket we'll want to use an approach similar to a7c256c to support inline.has_add_permission(request)
for a certain time.
tests/modeladmin/tests.py
Outdated
@@ -617,7 +617,6 @@ def test_log_actions(self): | |||
|
|||
|
|||
class ModelAdminPermissionTests(SimpleTestCase): | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make unrelated whitespace changes.
The ``has_add_permission`` method is given the HttpRequest and the parent ``obj``. | ||
Should return ``True`` if adding an instance is permitted, ``False`` otherwise. | ||
|
||
.. method:: InlineModelAdmin.has_change_permission(self, request, obj=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc changes for has_change_permission/has_delete_permission seem unrelated to the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the ticket it is not clear that obj refers to the parent instance, and not the inline instance. The documentation just points to the ModelAdmin.has_add_permission, ModelAdmin.has_change_permission, ModelAdmin.has_delete_permission though the actual use case differs.
…ion() - Backward compatibility for old api - Deprecated warning for the old api - Updated tests - Updated releases/2.0.txt
…ion() - Fixed documentations links - Removed duplicated test
Hi @icu0755 Are you still working on this PR? I'm interested in this feature. If you're too busy to continue or have otherwise moved on, I can continue the work if you'd like. If you'd like to continue the work, that works too. |
Hi @jdufresne. Please feel free to continue or start from scratch. Unfortunately I don't know how to proceed further. |
https://code.djangoproject.com/ticket/27991