def modification_action(target, *args, **kwargs): """ Check readonly mode and abort non admins """ request = request_from_args(args) if not is_admin(request) and request.registry.settings.get('karakara.system.user.readonly'): raise action_error(message='normal users are in readonly mode', code=403) return target(*args, **kwargs)
def admin_only(target, *args, **kwargs): """ Decorator to restrict view callable to admin users only todo - use pyramid's security framework """ request = request_from_args(args) if not is_admin(request): raise action_error(message='Administrators only', code=403) return target(*args, **kwargs)
def comunity_only(target, *args, **kwargs): """ Decorator to restrict view callable to approved comunity users only todo - use pyramid's security framework """ request = request_from_args(args) if not is_comunity(request): raise action_error(message='Approved comunity users only', code=403) return target(*args, **kwargs)