src/cm/security.py
changeset 81 720bafcca97d
parent 16 036705244cab
child 102 f5d3ea4bd03c
equal deleted inserted replaced
80:23294913284b 81:720bafcca97d
   118     ## only texts with role with perm
   118     ## only texts with role with perm
   119     #else:
   119     #else:
   120     #    return Text.objects.filter(Q(userrole__role__permissions__codename__exact=perm_name), Q(userrole__user=user) | Q(userrole__user=None)).distinct()
   120     #    return Text.objects.filter(Q(userrole__role__permissions__codename__exact=perm_name), Q(userrole__user=user) | Q(userrole__user=None)).distinct()
   121 
   121 
   122     # local role OVERRIDES global role:
   122     # local role OVERRIDES global role:
   123     texts_with_local_role = Text.objects.filter(userrole__in=UserRole.objects.filter(user=user).filter(~Q(role=None)))
   123     texts_with_local_role = Text.objects.filter(userrole__in=UserRole.objects.filter(user=user)) # .filter(~Q(role=None))
   124     #Text.objects.filter(Q(userrole__user=user) & ~Q(userrole__role=None))
   124     #Text.objects.filter(Q(userrole__user=user) & ~Q(userrole__role=None))
   125     texts_without_local_role = Text.objects.exclude(id__in=texts_with_local_role)
   125     texts_without_local_role = Text.objects.exclude(id__in=texts_with_local_role)
   126 
   126 
   127     texts_with_local_role_with_perm = Text.objects.filter(id__in=texts_with_local_role).filter(Q(userrole__role__permissions__codename__exact=perm_name), Q(userrole__user=user) | Q(userrole__user=None)).distinct()
   127     texts_with_local_role_with_perm = Text.objects.filter(id__in=texts_with_local_role).filter(Q(userrole__role__permissions__codename__exact=perm_name), Q(userrole__user=user) | Q(userrole__user=None)).distinct()
   128     
   128