wip: UI refactoring

Better behaviour on role change:
* If an account is promoted superuser, give it access to everything
* If an account is demoted from his position as superuser, remove all its accesses.

see #204
This commit is contained in:
Antoine Nguyen
2012-05-04 10:15:43 +02:00
parent a4fbb17c6c
commit a314c14fc4
3 changed files with 38 additions and 0 deletions
+16
View File
@@ -68,6 +68,22 @@ def grant_access_to_object(user, obj, is_owner=False):
except IntegrityError, e:
raise ModoboaException(_("Failed to grant access (%s)" % str(e)))
def grant_access_to_objects(user, objects, ct):
"""Grant access to a collection of objects
All objects in the collection must share the same type (ie. ``ct``
applies to all objects).
:param user: a ``User`` object
:param objects: a list of objects
:param ct: the content type
"""
for obj in objects:
try:
ObjectAccess.objects.create(user=user, content_type=ct, object_id=obj.id)
except IntegrityError:
pass
def ungrant_access_to_object(obj, user=None):
"""Ungrant access to an object for a specific user