houdini/houdini/permissions.py
2019-05-29 23:03:06 +01:00

14 lines
553 B
Python

from houdini.handlers import check
def has(permission_name, check_above=True):
def check_permission(_, p):
def check_permission_recursive(permissions, permission):
if permission in permissions:
return permissions[permission].enabled
if '.' in permission and check_above:
check_permission_recursive(permissions, '.'.join(permission.split('.')[:-1]))
return False
return check_permission_recursive(p.permissions, permission_name)
return check(check_permission)