예제 #1
0
파일: __init__.py 프로젝트: shish/KaraKara
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)
예제 #2
0
파일: __init__.py 프로젝트: shish/KaraKara
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)
예제 #3
0
파일: __init__.py 프로젝트: shish/KaraKara
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)