diff options
author | Gabriel Hurley <gabriel@strikeawe.com> | 2012-03-21 16:14:59 -0700 |
---|---|---|
committer | Gabriel Hurley <gabriel@strikeawe.com> | 2012-03-21 18:33:50 -0700 |
commit | c11cd9d1c5a4cfcc0120b5ab75564ef1d2df15f6 (patch) | |
tree | bfd3ff444d12b0af5e94e17fa7ea8b27b4f54950 /horizon/forms | |
parent | 0a640c300e63fbf866f0fde2d087fa812c6ec7bf (diff) | |
download | tuskar-ui-c11cd9d1c5a4cfcc0120b5ab75564ef1d2df15f6.tar.gz |
Implements AJAX form posting.
This is somewhat of a hack for Essex, since the long-term solution
is a reworking of the way AJAX is handled. But it solves problems
in the interim and provides a significantly better experience.
Thanks to Andy Chong for pushing forward with the initial attempts
which lead to this patch.
Fixes bug 943518.
Change-Id: Ia65d926d3d406b07301e23b4c87de60c66ddec75
Diffstat (limited to 'horizon/forms')
-rw-r--r-- | horizon/forms/views.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/horizon/forms/views.py b/horizon/forms/views.py index 7bd1a9c4..5b3ab7b3 100644 --- a/horizon/forms/views.py +++ b/horizon/forms/views.py @@ -16,6 +16,7 @@ import os +from django import http from django.views import generic @@ -62,6 +63,14 @@ class ModalFormView(generic.TemplateView): self.object = self.get_object(*args, **kwargs) form, handled = self.maybe_handle() if handled: + if self.request.is_ajax(): + # TODO(gabriel): This is not a long-term solution to how + # AJAX should be handled, but it's an expedient solution + # until the blueprint for AJAX handling is architected + # and implemented. + response = http.HttpResponse() + response['X-Horizon-Location'] = handled['location'] + return response return handled context = self.get_context_data(**kwargs) context[self.context_form_name] = form |