Permalink
Browse files

Fixed #11124 -- Expanded docstrings of the ModelAdmin has_{change|del…

…ete}_permission methods to make it clear they can be overriden to implement per-instance permission checks. Refs #12642.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15126 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 70c8cd4 commit 9c950db518fa2210b4f7963ee954148aba68cfaf @ramiro ramiro committed Jan 1, 2011
Showing with 16 additions and 7 deletions.
  1. +16 −7 django/contrib/admin/options.py
View
23 django/contrib/admin/options.py
@@ -340,28 +340,37 @@ def _media(self):
media = property(_media)
def has_add_permission(self, request):
- "Returns True if the given request has permission to add an object."
+ """
+ Returns True if the given request has permission to add an object.
+ Can be overriden by the user in subclasses.
+ """
opts = self.opts
return request.user.has_perm(opts.app_label + '.' + opts.get_add_permission())
def has_change_permission(self, request, obj=None):
"""
Returns True if the given request has permission to change the given
- Django model instance.
+ Django model instance, the default implementation doesn't examine the
+ `obj` parameter.
- If `obj` is None, this should return True if the given request has
- permission to change *any* object of the given type.
+ Can be overriden by the user in subclasses. In such case it should
+ return True if the given request has permission to change the `obj`
+ model instance. If `obj` is None, this should return True if the given
+ request has permission to change *any* object of the given type.
"""
opts = self.opts
return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())
def has_delete_permission(self, request, obj=None):
"""
Returns True if the given request has permission to change the given
- Django model instance.
+ Django model instance, the default implementation doesn't examine the
+ `obj` parameter.
- If `obj` is None, this should return True if the given request has
- permission to delete *any* object of the given type.
+ Can be overriden by the user in subclasses. In such case it should
+ return True if the given request has permission to delete the `obj`
+ model instance. If `obj` is None, this should return True if the given
+ request has permission to delete *any* object of the given type.
"""
opts = self.opts
return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission())

0 comments on commit 9c950db

Please sign in to comment.