

def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
    '\n    Decorator for views that checks that the user passes the given test,\n    redirecting to the log-in page if necessary. The test should be a callable\n    that takes the user object and returns True if the user passes.\n    '
    if (not test_func):
        from django.conf import settings
        login_url = settings.LOGIN_URL

    def decorator(view_func):

        def _wrapped_view(request, *args, **kwargs):
            if test_func(request.user):
                return view_func(request, *args, **kwargs)
            path = urlquote(request.get_full_path())
            tup = (login_url, redirect_field_name, path)
            return HttpResponseRedirect(('%s?%s=%s' % tup))
        return wraps(view_func, assigned=available_attrs(view_func))(_wrapped_view)
    return decorator

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/contrib/auth/decorators.py user_passes_test/VarMisuse@23/124 `login_url`->`test_func`