Skip to content

Commit

Permalink
Fix AJAX form posting that work incorrectly if get() in base views
Browse files Browse the repository at this point in the history
is overridden by subclass, e.g. EditRulesView and EditAttachmentsView
if they don't add X-Horizon-Location custom headers if redirect is
used. This mucking is probably the cleanest way to fix this in
the meantime.

 * fix bug 961863

Change-Id: I213e23a150b4afaba1249584e8cb3b376095533e
  • Loading branch information
andycjw committed Mar 22, 2012
1 parent 479ebdc commit 05b208f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions horizon/middleware.py
Expand Up @@ -80,3 +80,15 @@ def process_exception(self, request, exception):
if exception.message:
messages.error(request, exception.message)
return shortcuts.redirect(exception.location)

def process_response(self, request, response):
"""
Convert HttpResponseRedirect to HttpResponse if request is via ajax
to allow ajax request to redirect url
"""
if request.is_ajax():
if type(response) == http.HttpResponseRedirect:
redirect_response = http.HttpResponse()
redirect_response['X-Horizon-Location'] = response['location']
return redirect_response
return response

0 comments on commit 05b208f

Please sign in to comment.