1. Waldemar Kornewald
  2. djangotoolbox

Commits

fhahn  committed 3e1fadd

group_permissions aren't stored as strings in UserPermissionList anymore

  • Participants
  • Parent commits d011cb4
  • Branches default

Comments (0)

Files changed (2)

File djangotoolbox/auth/models.py

View file
     permission_list = ListField(models.CharField(max_length=128))
     permission_fk_list = ListField(models.CharField(max_length=32))
 
-    group_permission_list = ListField(models.CharField(max_length=128))
     group_fk_list = ListField(models.CharField(max_length=32))
 
     def _get_objs(self):

File djangotoolbox/auth/utils.py

View file
 from djangotoolbox.auth.models import UserPermissionList, GroupPermissionList
 
 
-def update_user_group_permissions(group_list):
-    """
-    updates UserPermissionList.group_permission_list everytime
-    permissions of a group are modified and everytime a user joins
-    or leaves a group
-    """
-
-    return True
-    perms = set()
-    if len(group_list.group_fk_list) > 0:
-        group_permissions = set()
-        group_permissions.update(GroupPermissionList.objects.filter(group__id__in=group_list.group_fk_list))
-        for group_perm in group_permissions:
-            perms.update(group_perm.permission_list)
-        
-    user_perm, created = UserPermissionList.objects.get_or_create(user=group_list.user)
-    user_perm.group_permission_list = list(perms)
-    user_perm.save()
-
 def add_perm_to(obj, list_cls, filter):
     obj_list, created = list_cls.objects.get_or_create(**filter)
     obj_list.permission_list.append('%s.%s' % (obj.content_type.app_label,\
     obj_list, created = UserPermissionList.objects.get_or_create(user=user)
     obj_list.group_fk_list.append(group.id)
     obj_list.save()
-    update_user_group_permissions(obj_list)
     
 def add_permission_to_group(perm, group):
     add_perm_to(perm, GroupPermissionList, {'group': group})
-    
-    group_list = UserPermissionList.objects.filter(group_fk_list=group.id)
-    for gl in group_list:
-        update_user_group_permissions(gl)
 
 def update_list(perm_objs, list_cls, filter):
     """
 def update_permissions_group(perms, group):
     update_list(perms, GroupPermissionList, {'group': group})
 
-    group_list = UserPermissionList.objects.filter(group_fk_list=group.id)
-    for gl in group_list:
-        update_user_group_permissions(gl)
-
 def update_user_groups(user, groups):
     new_group_ids = [ group.id for group in groups]
     pl, created = UserPermissionList.objects.get_or_create(user=user)
             pl.group_fk_list.append(group_id)
     
     pl.save()
-    
-    update_user_group_permissions(pl)