Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 9c950db518fa2210b4f7963ee954148aba68cfaf 1 parent 70c8cd4
Ramiro Morales authored January 01, 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
@@ -340,17 +340,23 @@ def _media(self):
340 340
     media = property(_media)
341 341
 
342 342
     def has_add_permission(self, request):
343  
-        "Returns True if the given request has permission to add an object."
  343
+        """
  344
+        Returns True if the given request has permission to add an object.
  345
+        Can be overriden by the user in subclasses.
  346
+        """
344 347
         opts = self.opts
345 348
         return request.user.has_perm(opts.app_label + '.' + opts.get_add_permission())
346 349
 
347 350
     def has_change_permission(self, request, obj=None):
348 351
         """
349 352
         Returns True if the given request has permission to change the given
350  
-        Django model instance.
  353
+        Django model instance, the default implementation doesn't examine the
  354
+        `obj` parameter.
351 355
 
352  
-        If `obj` is None, this should return True if the given request has
353  
-        permission to change *any* object of the given type.
  356
+        Can be overriden by the user in subclasses. In such case it should
  357
+        return True if the given request has permission to change the `obj`
  358
+        model instance. If `obj` is None, this should return True if the given
  359
+        request has permission to change *any* object of the given type.
354 360
         """
355 361
         opts = self.opts
356 362
         return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())
@@ -358,10 +364,13 @@ def has_change_permission(self, request, obj=None):
358 364
     def has_delete_permission(self, request, obj=None):
359 365
         """
360 366
         Returns True if the given request has permission to change the given
361  
-        Django model instance.
  367
+        Django model instance, the default implementation doesn't examine the
  368
+        `obj` parameter.
362 369
 
363  
-        If `obj` is None, this should return True if the given request has
364  
-        permission to delete *any* object of the given type.
  370
+        Can be overriden by the user in subclasses. In such case it should
  371
+        return True if the given request has permission to delete the `obj`
  372
+        model instance. If `obj` is None, this should return True if the given
  373
+        request has permission to delete *any* object of the given type.
365 374
         """
366 375
         opts = self.opts
367 376
         return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission())

0 notes on commit 9c950db

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