def user_passes_test(test_func, login_url=None, message=None):
    if not login_url:
        from .utils import get_login_url
        login_url = get_login_url()

    def decorator(view_func):
        def _wrapped_view(request, *args, **kwargs):
            if test_func(request.user):
                return view_func(request, *args, **kwargs)

            if message is not None:
                messages.info(request, message, fail_silently=True)

            response = HttpResponseRedirect(login_url)

            if request.method != 'GET':
                from .helpers import save_next_action

                data = {
                    'action': request.META.get('PATH_INFO'),
                    'args': args,
                    'kwargs': kwargs,
                    'method': request.method,
                    'parameters': {
                        'POST': request.POST.urlencode() if request.POST else None,
                    }
                }

                save_next_action(request, response, data)

            return response
        return wraps(view_func, assigned=available_attrs(view_func))(_wrapped_view)
    return decorator
Returns a copy of this object.
dataset/ETHPy150Open thoas/django-backward/backward/decorators.py/user_passes_test--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/webob-1.1.1/webob/cachecontrol.py/CacheControl.copy