Correctly set content-type for workflow response

The default content-type is html, and under certain
circumstances like devstack the html has some additional
comments added. Because this specific content is meant
to be parsed as json those extra html comments break the
modal.js code.

We can't set the content-type to json without rewriting parts of
modal.js, as it will will parse it into an object early and then
modal.js will fail as it attempts to parse an object into json.

Change-Id: If5a9ee7fe4273dc368dec7767a55d4467bf6a1a7
Closes-bug: #1824484
This commit is contained in:
Adrian Turjak 2019-04-12 20:24:46 +12:00
parent b028b5a0aa
commit 8516de8f61
1 changed files with 2 additions and 1 deletions

View File

@ -192,7 +192,8 @@ class ModalFormView(ModalFormMixin, views.HorizonFormView):
field_id = self.request.META[ADD_TO_FIELD_HEADER]
data = [self.get_object_id(handled),
self.get_object_display(handled)]
response = http.HttpResponse(json.dumps(data))
response = http.HttpResponse(
json.dumps(data), content_type="text/plain")
response["X-Horizon-Add-To-Field"] = field_id
elif isinstance(handled, http.HttpResponse):
return handled