(permission_check,
                           login_decorator=login_and_domain_required,
                           view_only_permission_check=None,
                           permission_check_v2=None)
return decorator
A way to do more fine-grained permissions via decorator. The permission_check should be
    a function that takes in a couch_user and a domain and returns True if that user can access
    the page, otherwise false.

    If `permission_check_v2` is specified it will be used instead of permission_check.
    This is to allow for changing the permission-checking API without having to update every
    call at the same time.

    permission_check_v2 takes in a *request* instead of a *user* so it can do more explicit
    checking (e.g. check the exact API key that was used).
A way to do more fine-grained permissions via decorator. The permission_check should be
    a function that takes in a couch_user and a domain and returns True if that user can access
    the page, otherwise false.
A way to do more fine - grained permissions via decorator . The permission_check should be a function that takes in a couch_user and a domain and returns True if that user can access the page otherwise false .
def require_permission_raw(permission_check,
                           login_decorator=login_and_domain_required,
                           view_only_permission_check=None,
                           permission_check_v2=None):
    """
    A way to do more fine-grained permissions via decorator. The permission_check should be
    a function that takes in a couch_user and a domain and returns True if that user can access
    the page, otherwise false.

    If `permission_check_v2` is specified it will be used instead of permission_check.
    This is to allow for changing the permission-checking API without having to update every
    call at the same time.

    permission_check_v2 takes in a *request* instead of a *user* so it can do more explicit
    checking (e.g. check the exact API key that was used).
    """
    def decorator(view_func):
        @wraps(view_func)
        def _inner(request, domain, *args, **kwargs):
            if not hasattr(request, "couch_user"):
                return redirect_for_login_or_domain(request)
            elif permission_check_v2 is not None:
                if permission_check_v2(request, domain):
                    return view_func(request, domain, *args, **kwargs)
                else:
                    raise PermissionDenied()
            elif request.user.is_superuser or permission_check(request.couch_user, domain):
                request.is_view_only = False
                return view_func(request, domain, *args, **kwargs)
            elif (view_only_permission_check is not None
                  and view_only_permission_check(request.couch_user, domain)):
                request.is_view_only = True
                return view_func(request, domain, *args, **kwargs)
            else:
                if request.is_ajax():
                    return HttpResponse(_("Sorry, you don't have permission to do this action!"), status=403)
                raise PermissionDenied()

        if login_decorator:
            return login_decorator(_inner)
        else:
            return _inner

    return decorator
def require_permission_raw ( permission_check , login_decorator = login_and_domain_required , view_only_permission_check = None , permission_check_v2 = None ) : def decorator ( view_func ) : @ wraps ( view_func ) def _inner ( request , domain , * args , * * kwargs ) : if not hasattr ( request , "couch_user" ) : return redirect_for_login_or_domain ( request ) elif permission_check_v2 is not None : if permission_check_v2 ( request , domain ) : return view_func ( request , domain , * args , * * kwargs ) else : raise PermissionDenied ( ) elif request . user . is_superuser or permission_check ( request . couch_user , domain ) : request . is_view_only = False return view_func ( request , domain , * args , * * kwargs ) elif ( view_only_permission_check is not None and view_only_permission_check ( request . couch_user , domain ) ) : request . is_view_only = True return view_func ( request , domain , * args , * * kwargs ) else : if request . is_ajax ( ) : return HttpResponse ( _ ( "Sorry, you don't have permission to do this action!" ) , status = 403 ) raise PermissionDenied ( ) if login_decorator : return login_decorator ( _inner ) else : return _inner return decorator