Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
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)