1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-27 02:43:01 +00:00

[permission] Only split permission up to 3

This commit is contained in:
Benjamin Graillot 2020-03-07 11:21:19 +01:00
parent 5df1f42f43
commit 9d61e217e9

View File

@ -21,7 +21,7 @@ class PermissionBackend(object):
def has_perm(self, user_obj, perm, obj=None): def has_perm(self, user_obj, perm, obj=None):
if obj is None: if obj is None:
return False return False
perm = perm.split('_') perm = perm.split('_', 3)
perm_type = perm[1] perm_type = perm[1]
perm_field = perm[2] if len(perm) == 3 else None perm_field = perm[2] if len(perm) == 3 else None
return any(permission.applies(obj, perm_type, perm_field) for obj in self.permissions(user_obj, obj)) return any(permission.applies(obj, perm_type, perm_field) for obj in self.permissions(user_obj, obj))