Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #11124 -- Expanded docstrings of the ModelAdmin has_{ch…

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

Backport of [15126] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15179 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 10ca44ba8daca7258747d5c6bf16e8763a4e6ca6 1 parent 90be6ca
Ramiro Morales authored January 12, 2011

Showing 1 changed file with 16 additions and 7 deletions. Show diff stats Hide diff stats

  1. 23  django/contrib/admin/options.py
23  django/contrib/admin/options.py
@@ -322,17 +322,23 @@ def _media(self):
322 322
     media = property(_media)
323 323
 
324 324
     def has_add_permission(self, request):
325  
-        "Returns True if the given request has permission to add an object."
  325
+        """
  326
+        Returns True if the given request has permission to add an object.
  327
+        Can be overriden by the user in subclasses.
  328
+        """
326 329
         opts = self.opts
327 330
         return request.user.has_perm(opts.app_label + '.' + opts.get_add_permission())
328 331
 
329 332
     def has_change_permission(self, request, obj=None):
330 333
         """
331 334
         Returns True if the given request has permission to change the given
332  
-        Django model instance.
  335
+        Django model instance, the default implementation doesn't examine the
  336
+        `obj` parameter.
333 337
 
334  
-        If `obj` is None, this should return True if the given request has
335  
-        permission to change *any* object of the given type.
  338
+        Can be overriden by the user in subclasses. In such case it should
  339
+        return True if the given request has permission to change the `obj`
  340
+        model instance. If `obj` is None, this should return True if the given
  341
+        request has permission to change *any* object of the given type.
336 342
         """
337 343
         opts = self.opts
338 344
         return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())
@@ -340,10 +346,13 @@ def has_change_permission(self, request, obj=None):
340 346
     def has_delete_permission(self, request, obj=None):
341 347
         """
342 348
         Returns True if the given request has permission to change the given
343  
-        Django model instance.
  349
+        Django model instance, the default implementation doesn't examine the
  350
+        `obj` parameter.
344 351
 
345  
-        If `obj` is None, this should return True if the given request has
346  
-        permission to delete *any* object of the given type.
  352
+        Can be overriden by the user in subclasses. In such case it should
  353
+        return True if the given request has permission to delete the `obj`
  354
+        model instance. If `obj` is None, this should return True if the given
  355
+        request has permission to delete *any* object of the given type.
347 356
         """
348 357
         opts = self.opts
349 358
         return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission())

0 notes on commit 10ca44b

Please sign in to comment.
Something went wrong with that request. Please try again.