'Convert HttpResponseRedirect to HttpResponse if request is via ajax.
This is to allow ajax request to redirect url.'

def process_response(self, request, response):

    if (request.is_ajax() and hasattr(request, 'horizon')):
        queued_msgs = request.horizon['async_messages']
        if (type(response) == http.HttpResponseRedirect):
            for (tag, message, extra_tags) in queued_msgs:
                getattr(django_messages, tag)(request, message, extra_tags)
            if response['location'].startswith(settings.LOGOUT_URL):
                redirect_response = http.HttpResponse(status=401)
                redirect_response['logout'] = True
                if (self.logout_reason is not None):
                    utils.add_logout_reason(request, redirect_response, self.logout_reason, 'error')
            else:
                redirect_response = http.HttpResponse()
            cookie_keys = {'max_age', 'expires', 'path', 'domain', 'secure', 'httponly', 'logout_reason'}
            for (cookie_name, cookie) in response.cookies.items():
                cookie_kwargs = dict(((key, value) for (key, value) in cookie.items() if ((key in cookie_keys) and value)))
                redirect_response.set_cookie(cookie_name, cookie.value, **cookie_kwargs)
            redirect_response['X-Horizon-Location'] = response['location']
            upload_url_key = 'X-File-Upload-URL'
            if (upload_url_key in response):
                self.copy_headers(response, redirect_response, (upload_url_key, 'X-Auth-Token'))
            return redirect_response
        if queued_msgs:
            response['X-Horizon-Messages'] = json.dumps(queued_msgs)
    return response
