Commits

Kai Diefenbach  committed 8586310

Added reset method to utils

  • Participants
  • Parent commits ad1c4d8

Comments (0)

Files changed (1)

File permissions/utils.py

     except Group.DoesNotExist:
         return None
 
+def reset(obj):
+    """Resets all permissions and inheritance blocks of passed object.
+    """
+    ctype = ContentType.objects.get_for_model(obj)
+    ObjectPermissionInheritanceBlock.objects.filter(content_id=obj.id, content_type=ctype).delete()
+    ObjectPermission.objects.filter(content_id=obj.id, content_type=ctype).delete()
+
 # Registering ################################################################
 
 def register_permission(name, codename, ctypes=[]):