def create_permissions_for_module(cls,module): """ creates the permissions of a newly installed module """ rootuser = User.get_root_user() module_name = module.get_name() permissions = module.get_permissions() for permission in permissions: new_permission = cls.create_permission(permission,module_name) rootuser.grant_permission(new_permission,ignore_check=True)
def update_permissions_for_module(cls,module): """ updates the permissions of a module """ rootuser = User.get_root_user() module_name = module.get_name() permissions = module.get_permissions() current = [s.replace(module_name+".","",1) for s in cls.get_permissions_for_module(module)] for permission in permissions: if permission not in current: new_permission = cls.create_permission(permission, module_name) rootuser.grant_permission(new_permission,ignore_check=True) for permission in current: if permission not in permissions: cls.remove_permission(permission, module_name)