src/ldt/ldt/security/utils.py
author ymh <ymh.work@gmail.com>
Sun, 23 Aug 2015 22:37:27 +0200
changeset 1414 9c76c7eea3fd
parent 1360 f69b5d8ba4b9
permissions -rw-r--r--
Added tag V01.57.02 for changeset 91faf761b6c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
     1
from cache import get_cached_userlist, cached_assign
239
352be36c9fd7 Moved code about group security into a separate module
verrierj
parents:
diff changeset
     2
from django.conf import settings
352be36c9fd7 Moved code about group security into a separate module
verrierj
parents:
diff changeset
     3
from django.contrib.contenttypes.models import ContentType
549
0313c23ffe7e Minor bugs about permission caching
verrierj
parents: 503
diff changeset
     4
from django.core.cache import cache
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
     5
from guardian.shortcuts import (remove_perm, get_users_with_perms, 
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
     6
    get_groups_with_perms, get_objects_for_user)
1013
7b5c49cab8f1 remove useless template and unused import.
cavaliet
parents: 840
diff changeset
     7
from ldt.security import change_security
340
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
     8
import types
1093
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
     9
350
c6953232099f Anonymous users can see pages even if they are not logged in + factor code to decrease number of SQL requests
verrierj
parents: 340
diff changeset
    10
  
340
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    11
def unprotect_instance(instance):
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    12
    if hasattr(instance, 'old_save'):
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    13
        instance.save = instance.old_save
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    14
        instance.delete = instance.old_delete
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    15
        
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    16
def protect_instance(instance):
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    17
    class_name = instance.__class__.__name__.lower()
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    18
    cls = ContentType.objects.get(model=class_name)
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    19
    cls = cls.model_class()
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    20
    
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    21
    save = types.MethodType(change_security('project')(cls.save), instance, cls)
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    22
    instance.save = save
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    23
    
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    24
    delete = types.MethodType(change_security('project')(cls.delete), instance, cls)
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    25
    instance.delete = delete
5f919a978f50 Stats for annotations volume can be computed using ./manage.py statannotation [-c content_id] or in the admin pages of module ldt_utils.
verrierj
parents: 292
diff changeset
    26
        
239
352be36c9fd7 Moved code about group security into a separate module
verrierj
parents:
diff changeset
    27
245
953228fcbb56 Permissions are checked in search results
verrierj
parents: 242
diff changeset
    28
def set_forbidden_stream(xml, user):
953228fcbb56 Permissions are checked in search results
verrierj
parents: 242
diff changeset
    29
    cls = ContentType.objects.get(model='content')
953228fcbb56 Permissions are checked in search results
verrierj
parents: 242
diff changeset
    30
    cls = cls.model_class()
953228fcbb56 Permissions are checked in search results
verrierj
parents: 242
diff changeset
    31
    
1093
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    32
    m_cls = ContentType.objects.get(model='media')
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    33
    m_cls = m_cls.model_class()
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    34
    
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    35
    content_ids = xml.xpath('/iri/medias/media/@id')
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    36
    contents = dict( [(c.iri_id, c) for c in cls.safe_objects.filter(iri_id__in=content_ids).select_related("media_obj")])
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    37
    
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    38
    medias = dict([(m.id,m) for m in m_cls.safe_objects.filter(id__in=[c.media_obj.id for c in contents.values()])])
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    39
            
245
953228fcbb56 Permissions are checked in search results
verrierj
parents: 242
diff changeset
    40
    for elem in xml.xpath('/iri/medias/media'):
1093
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    41
        content = contents.get(elem.get('id'), None)
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    42
        if content and (content.media_obj and content.media_obj.id not in medias) :
245
953228fcbb56 Permissions are checked in search results
verrierj
parents: 242
diff changeset
    43
            elem.set('video', settings.FORBIDDEN_STREAM_URL)
953228fcbb56 Permissions are checked in search results
verrierj
parents: 242
diff changeset
    44
    return xml
953228fcbb56 Permissions are checked in search results
verrierj
parents: 242
diff changeset
    45
482
c802e00c7131 Lot of bugfixes
verrierj
parents: 350
diff changeset
    46
def use_forbidden_url(content):
795
923429f142ea Possibility to list a content on the front or not, with a private media. A media can be private, and the content public (listed or not)
rougeronj
parents: 549
diff changeset
    47
    m_cls = ContentType.objects.get(model='media')
923429f142ea Possibility to list a content on the front or not, with a private media. A media can be private, and the content public (listed or not)
rougeronj
parents: 549
diff changeset
    48
    m_cls = m_cls.model_class()
923429f142ea Possibility to list a content on the front or not, with a private media. A media can be private, and the content public (listed or not)
rougeronj
parents: 549
diff changeset
    49
    
1093
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    50
    if content.media_obj:
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    51
        media = m_cls.safe_objects.filter(id=content.media_obj.id)
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    52
        if not media:
03104d3f6ca1 Requests optimisations
ymh <ymh.work@gmail.com>
parents: 1013
diff changeset
    53
            return True
795
923429f142ea Possibility to list a content on the front or not, with a private media. A media can be private, and the content public (listed or not)
rougeronj
parents: 549
diff changeset
    54
    return False
482
c802e00c7131 Lot of bugfixes
verrierj
parents: 350
diff changeset
    55
251
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    56
def add_change_attr(user, obj_list):
274
80375a7b7e14 Improve permissions of medias + fix css
verrierj
parents: 273
diff changeset
    57
    """ 
80375a7b7e14 Improve permissions of medias + fix css
verrierj
parents: 273
diff changeset
    58
     Add a change attribute set to True to objects of obj_list
80375a7b7e14 Improve permissions of medias + fix css
verrierj
parents: 273
diff changeset
    59
     if permissions change_object is set with respect to user.
80375a7b7e14 Improve permissions of medias + fix css
verrierj
parents: 273
diff changeset
    60
    """
251
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    61
    if len(obj_list) == 0:
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    62
        return []
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    63
    model_name = obj_list[0].__class__.__name__.lower()
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    64
    ctype = ContentType.objects.get(model=model_name)
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    65
    cls = ctype.model_class()
1146
4491284e73bb optimisation to open and save projects
cavaliet
parents: 1013
diff changeset
    66
    # We don't use obj.values_list('pk', flat=True) because the full queryset will be calculated and used after anyway.
4491284e73bb optimisation to open and save projects
cavaliet
parents: 1013
diff changeset
    67
    pk_list = [item.pk for item in obj_list]
290
e1980a7d4b83 Fix bug when checking for add_group permission
verrierj
parents: 289
diff changeset
    68
    if model_name in [cls_name.lower() for cls_name in settings.USE_GROUP_PERMISSIONS] or model_name == 'group':
289
f78273a17bb3 Speed up response time when retrieving group projects
verrierj
parents: 285
diff changeset
    69
        to_check = True
1146
4491284e73bb optimisation to open and save projects
cavaliet
parents: 1013
diff changeset
    70
        # Filter SUPER usefull : avoid to load ALL objects. We only check permissions on obj_list's objects
4491284e73bb optimisation to open and save projects
cavaliet
parents: 1013
diff changeset
    71
        change_list = get_objects_for_user(user, '%s.change_%s' % (cls._meta.app_label, model_name)).filter(pk__in=pk_list)
274
80375a7b7e14 Improve permissions of medias + fix css
verrierj
parents: 273
diff changeset
    72
    else:
1146
4491284e73bb optimisation to open and save projects
cavaliet
parents: 1013
diff changeset
    73
        to_check = False
1132
026d510a3dc3 Finally super useful optimization on guardian request.
cavaliet
parents: 1093
diff changeset
    74
    
251
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    75
    for obj in obj_list:
289
f78273a17bb3 Speed up response time when retrieving group projects
verrierj
parents: 285
diff changeset
    76
        if not to_check or obj in change_list:
251
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    77
            obj.change = True
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    78
        else:
81417fd477b0 Display specific tooltip when project edition is not allowed
verrierj
parents: 245
diff changeset
    79
            obj.change = False
1132
026d510a3dc3 Finally super useful optimization on guardian request.
cavaliet
parents: 1093
diff changeset
    80
    
274
80375a7b7e14 Improve permissions of medias + fix css
verrierj
parents: 273
diff changeset
    81
    return obj_list
269
4b8042fc3d33 Moved Share to form to security module
verrierj
parents: 268
diff changeset
    82
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    83
def assign_perm_to_obj(obj, read_list, write_list, owner):
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    84
    name = obj.__class__.__name__.lower()
268
c0c161736794 Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents: 265
diff changeset
    85
    
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    86
    old_users = get_users_with_perms(obj).exclude(id=owner.id)
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    87
    old_groups = get_groups_with_perms(obj)
268
c0c161736794 Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents: 265
diff changeset
    88
    
c0c161736794 Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents: 265
diff changeset
    89
    for elem in read_list:
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    90
        cached_assign('view_%s' % name, elem, obj)
268
c0c161736794 Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents: 265
diff changeset
    91
        if elem in write_list:
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    92
            cached_assign('change_%s' % name, elem, obj)
239
352be36c9fd7 Moved code about group security into a separate module
verrierj
parents:
diff changeset
    93
        else:
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    94
            remove_perm('change_%s' % name, elem, obj) 
268
c0c161736794 Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents: 265
diff changeset
    95
                
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    96
    def remove_perms(new_list, old_list, o, name):
268
c0c161736794 Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents: 265
diff changeset
    97
        for e in old_list:
c0c161736794 Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents: 265
diff changeset
    98
            if e not in new_list:
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
    99
                remove_perm('view_%s' % name, e, o)
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
   100
                remove_perm('change_%s' % name, e, o)
268
c0c161736794 Projects can be shared with users and groups. Does not work with contents yet, still some bugs in templates
verrierj
parents: 265
diff changeset
   101
                
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
   102
    remove_perms(read_list, old_users, obj, name)
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
   103
    remove_perms(read_list, old_groups, obj, name)
1357
dd3b4c9d5035 add command to create media and content
ymh <ymh.work@gmail.com>
parents: 1193
diff changeset
   104
    cache.delete('userlist')
549
0313c23ffe7e Minor bugs about permission caching
verrierj
parents: 503
diff changeset
   105
 
269
4b8042fc3d33 Moved Share to form to security module
verrierj
parents: 268
diff changeset
   106
    
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
   107
def get_userlist(user, filter=None):  # @ReservedAssignment
282
7512c33b64be Add cache to userlist
verrierj
parents: 281
diff changeset
   108
    user_list = get_cached_userlist().exclude(id=user.id)
281
832c5049b358 Factor code to display userlist in project/content edition
verrierj
parents: 279
diff changeset
   109
    if filter:
832c5049b358 Factor code to display userlist in project/content edition
verrierj
parents: 279
diff changeset
   110
        user_list = user_list.filter(username__icontains=filter)
832c5049b358 Factor code to display userlist in project/content edition
verrierj
parents: 279
diff changeset
   111
    elem_list = [{'name': u.username, 'id': u.id, 'type': 'user'} for u in user_list[0:settings.MAX_USERS_SEARCH]]
832c5049b358 Factor code to display userlist in project/content edition
verrierj
parents: 279
diff changeset
   112
    return elem_list  
832c5049b358 Factor code to display userlist in project/content edition
verrierj
parents: 279
diff changeset
   113
1190
129d45eec68c Clean warning and errors for Django 1.5
ymh <ymh.work@gmail.com>
parents: 1180
diff changeset
   114
def get_userlist_model(object, owner):  # @ReservedAssignment
275
a14509d74e13 Change modal window size + improve get_urserlist_model function for public contents
verrierj
parents: 274
diff changeset
   115
    if hasattr(object, 'is_public') and object.is_public:
a14509d74e13 Change modal window size + improve get_urserlist_model function for public contents
verrierj
parents: 274
diff changeset
   116
        return [None, None]
a14509d74e13 Change modal window size + improve get_urserlist_model function for public contents
verrierj
parents: 274
diff changeset
   117
    
285
1cc364d7b298 Fix bug in project copy from group tab
verrierj
parents: 282
diff changeset
   118
    users = get_users_with_perms(object, attach_perms=True, with_group_users=False)
273
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   119
    groups = get_groups_with_perms(object, attach_perms=True)
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   120
    object_name = object.__class__.__name__.lower()
263
eba92ea32281 Ask confirmation when user leaves a group
verrierj
parents: 260
diff changeset
   121
    
273
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   122
    def create_dict (users_or_groups, name, groups=True):
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   123
        l = []
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   124
        admin_list = []
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   125
        
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   126
        for elem in users_or_groups.keys():
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   127
            if elem == owner:
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   128
                continue
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   129
                        
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   130
            if groups:
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   131
                elem_dict = {'name': elem.name, 'type': 'group', 'id': elem.id}
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   132
            else:
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   133
                elem_dict = {'name': elem.username, 'type': 'user', 'id': elem.id}
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   134
            
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   135
            for perm in users_or_groups[elem]:
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   136
                if perm == 'change_%s' % name:
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   137
                    elem_dict['change'] = True
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   138
                    admin_list.append(elem_dict)
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   139
                    continue
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   140
                
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   141
            l.append(elem_dict)   
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   142
        return l, admin_list
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   143
    
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   144
    users_list, admin_users = create_dict(users, object_name, False)
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   145
    groups_list, admin_groups = create_dict(groups, object_name, True)
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   146
    
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   147
    return [users_list + groups_list, admin_users + admin_groups]
285
1cc364d7b298 Fix bug in project copy from group tab
verrierj
parents: 282
diff changeset
   148
 
273
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   149
def get_userlist_group(group, user):
1360
f69b5d8ba4b9 started upgrading to Django 1.6: fixed transactions, settings, switched django_social_auth to python_social_auth
ndurand
parents: 1357
diff changeset
   150
    members = group.user_set.all()
273
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   151
    admin = get_users_with_perms(group)
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   152
269
4b8042fc3d33 Moved Share to form to security module
verrierj
parents: 268
diff changeset
   153
    member_list = []
273
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   154
    for u in members:
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   155
        if u == user:
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   156
            continue
278
d16ec14aaf29 Add methods to set user in current thread
verrierj
parents: 275
diff changeset
   157
        u_dict = {'name': u.username, 'id': u.id, 'type': 'user', 'change': False}
273
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   158
        if u in admin:
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   159
            u_dict['change'] = True
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   160
        member_list.append(u_dict)
269
4b8042fc3d33 Moved Share to form to security module
verrierj
parents: 268
diff changeset
   161
        
278
d16ec14aaf29 Add methods to set user in current thread
verrierj
parents: 275
diff changeset
   162
    admin_list = [{'name': e.username, 'id': e.id, 'type': 'user', 'change': False} for e in admin]
269
4b8042fc3d33 Moved Share to form to security module
verrierj
parents: 268
diff changeset
   163
    
273
23a756e0bfee Fix bug in group form
verrierj
parents: 269
diff changeset
   164
    return [member_list, admin_list]