Commits

cl...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed 38f41d4

[per-object-permissions] Fixed up some comments

  • Participants
  • Parent commits b989a49
  • Branches per-object-permissions

Comments (0)

Files changed (3)

File django/contrib/admin/views/row_level_permissions.py

     
     if not request.user.has_perm(opts.app_label + '.' + opts.get_change_permission(), object=model_instance):
         raise PermissionDenied
-    if not request.user.has_perm(RowLevelPermission._meta.app_label + '.' + RowLevelPermission._meta.get_change_permission()):
+    if not (request.user.has_perm(RowLevelPermission._meta.app_label + '.' + RowLevelPermission._meta.get_change_permission()) or
+            request.user.has_perm(RowLevelPermission._meta.app_label + '.' + RowLevelPermission._meta.get_add_permission())):
         raise PermissionDenied    
     
     c = template.RequestContext(request, {
         'opts':opts,
     })   
 
+
+    #Set up the paging
     list_per_page = RowLevelPermission._meta.admin.list_per_page
     paginator = ObjectPaginator(model_instance.row_level_permissions.order_by('owner_ct', 'owner_id'),
                                 list_per_page)
     add_rlp_manip = AddRLPManipulator(model_instance, model_ct)
     edit_rlp_manip = ChangeRLPManipulator(model_ct)
     new_rlp_form = forms.FormWrapper(add_rlp_manip, rlp_new_data, rlp_errors)
-    
+    #3 different groups of forms when split by owner
     user_rlp_form_list = []
     other_rlp_form_list = []
     group_rlp_form_list = []
             group_rlp_form_list.append({'form':forms.FormWrapper(edit_rlp_manip, data, rlp_errors), 'rlp':r})            
         else:
             other_rlp_form_list.append({'form':forms.FormWrapper(edit_rlp_manip, data, rlp_errors), 'rlp':r})
-    
+    #Combine together the three kinds 
     rlp_forms = []
     if user_rlp_form_list:
         rlp_forms.append((_('Users'), user_rlp_form_list,))

File django/contrib/auth/models.py

         return True
 
     def contains_permission(self, perm, model=None):
+        """
+        This checks if the user has the given permission for any instance 
+        of the given model.
+        """
         if self.has_perm(perm):
             return True
         if model and model._meta.row_level_permissions:

File tests/modeltests/row_level_permissions/models.py

 >>> user.has_perm(quartz._meta.app_label +"."+ perm.codename, quartz)
 False
 
-
 """