def METHOD_NAME(view_func):
    # decorator takes the view function, and returns the view wrapped in
    # a permission check
    @wraps(view_func)
    def wrapped_view_func(request, *args, **kwargs):
        if test(request.user):
            # permission check succeeds; run the view function as normal
            return view_func(request, *args, **kwargs)
        else:
            # permission check failed
            return permission_denied(request)
    return wrapped_view_func