hilbert/decorators.py
def ajax_login_required(view_func):
    """Handle non-authenticated users differently if it is an AJAX request."""

    @wraps(view_func, assigned=available_attrs(view_func))
    def _wrapped_view(request, *args, **kwargs):
        if request.is_ajax():
            if request.user.is_authenticated():
                return view_func(request, *args, **kwargs)
            else:
                response = http.HttpResponse()
                response['X-Django-Requires-Auth'] = True
                response['X-Django-Login-Url'] = settings.LOGIN_URL
                return response
        else:
            return login_required(view_func)(request, *args, **kwargs)
    return _wrapped_view
Handle non-authenticated users differently if it is an AJAX request.
Handle non-authenticated users differently if it is an AJAX request.
Handle non - authenticated users differently if it is an AJAX request .
def ajax_login_required(view_func):
    @wraps(view_func, assigned=available_attrs(view_func))
    def _wrapped_view(request, *args, **kwargs):
        if request.is_ajax():
            if request.user.is_authenticated():
                return view_func(request, *args, **kwargs)
            else:
                response = http.HttpResponse()
                response['X-Django-Requires-Auth'] = True
                response['X-Django-Login-Url'] = settings.LOGIN_URL
                return response
        else:
            return login_required(view_func)(request, *args, **kwargs)
    return _wrapped_view
def ajax_login_required ( view_func ) : @ wraps ( view_func , assigned = available_attrs ( view_func ) ) def _wrapped_view ( request , * args , ** kwargs ) : if request . is_ajax ( ) : if request . user . is_authenticated ( ) : return view_func ( request , * args , ** kwargs ) else : response = http . HttpResponse ( ) response [ 'X-Django-Requires-Auth' ] = True response [ 'X-Django-Login-Url' ] = settings . LOGIN_URL return response else : return login_required ( view_func ) ( request , * args , ** kwargs ) return _wrapped_view
Handle non-authenticated users differently if it is an AJAX request.
Handle non - authenticated users differently if it is an AJAX request .
"""Handle non-authenticated users differently if it is an AJAX request."""
view_func