Author: ramiro
Date: 2010-12-31 18:37:38 -0600 (Fri, 31 Dec 2010)
New Revision: 15126
Modified:
django/trunk/django/contrib/admin/options.py
Log:
Fixed #11124 -- Expanded docstrings of the ModelAdmin
has_{change|delete}_permission methods to make it clear they can be overriden
to implement per-instance permission checks. Refs #12642.
Modified: django/trunk/django/contrib/admin/options.py
===================================================================
--- django/trunk/django/contrib/admin/options.py 2010-12-31 23:06:07 UTC
(rev 15125)
+++ django/trunk/django/contrib/admin/options.py 2011-01-01 00:37:38 UTC
(rev 15126)
@@ -340,17 +340,23 @@
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())
@@ -358,10 +364,13 @@
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())
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.