Skip to content

Decorators

hypha.apply.users.decorators

staff_required module-attribute

staff_required = [login_required, user_passes_test(is_apply_staff)]

staff_admin_required module-attribute

staff_admin_required = [login_required, user_passes_test(is_apply_staff_admin)]

finance_required module-attribute

finance_required = [login_required, user_passes_test(is_finance)]

staff_or_reviewer_required module-attribute

staff_or_reviewer_required = [login_required, user_passes_test(is_apply_staff_or_reviewer_required)]

staff_or_finance_required module-attribute

staff_or_finance_required = [login_required, user_passes_test(is_apply_staff_or_finance)]

approver_required module-attribute

approver_required = [login_required, user_passes_test(is_approver)]

staff_or_finance_or_contracting_required module-attribute

staff_or_finance_or_contracting_required = [login_required, user_passes_test(is_apply_staff_or_finance_or_contracting)]

contracting_approver_required module-attribute

contracting_approver_required = [login_required, user_passes_test(is_contracting_approver)]

require_oauth_whitelist

require_oauth_whitelist(view_func)

Simple decorator that limits the use of OAuth to the configure whitelisted domains

Source code in hypha/apply/users/decorators.py
def require_oauth_whitelist(view_func):
    """Simple decorator that limits the use of OAuth to the configure whitelisted domains"""

    def decorated_view(request, *args, **kwargs):
        if can_use_oauth_check(request.user):
            return view_func(request, *args, **kwargs)
        raise PermissionDenied

    return decorated_view

is_apply_staff

is_apply_staff(user)
Source code in hypha/apply/users/decorators.py
def is_apply_staff(user):
    if not user.is_apply_staff:
        raise PermissionDenied
    return True

is_apply_staff_admin

is_apply_staff_admin(user)
Source code in hypha/apply/users/decorators.py
def is_apply_staff_admin(user):
    if not user.is_apply_staff_admin:
        raise PermissionDenied
    return True

is_finance

is_finance(user)
Source code in hypha/apply/users/decorators.py
def is_finance(user):
    if not user.is_finance:
        raise PermissionDenied
    return True

is_apply_staff_or_finance

is_apply_staff_or_finance(user)
Source code in hypha/apply/users/decorators.py
def is_apply_staff_or_finance(user):
    if not (user.is_apply_staff or user.is_finance):
        raise PermissionDenied
    return True

is_apply_staff_or_reviewer_required

is_apply_staff_or_reviewer_required(user)
Source code in hypha/apply/users/decorators.py
def is_apply_staff_or_reviewer_required(user):
    if not (user.is_apply_staff or user.is_reviewer):
        raise PermissionDenied
    return True

is_apply_staff_or_finance_or_contracting

is_apply_staff_or_finance_or_contracting(user)
Source code in hypha/apply/users/decorators.py
def is_apply_staff_or_finance_or_contracting(user):
    if not (user.is_apply_staff or user.is_finance or user.is_contracting):
        raise PermissionDenied
    return True

is_approver

is_approver(user)
Source code in hypha/apply/users/decorators.py
def is_approver(user):
    if not user.is_approver:
        raise PermissionDenied
    return True

is_contracting_approver

is_contracting_approver(user)
Source code in hypha/apply/users/decorators.py
def is_contracting_approver(user):
    if not user.is_approver or not user.is_contracting:
        raise PermissionDenied
    return True

superuser_decorator

superuser_decorator(fn)
Source code in hypha/apply/users/decorators.py
def superuser_decorator(fn):
    check = user_passes_test(lambda user: user.is_superuser)
    return check(fn)

has_dashboard_access

has_dashboard_access(user)
Source code in hypha/apply/users/decorators.py
def has_dashboard_access(user):
    return user.can_access_dashboard