Revert "Tidy up render_modal_workflow"

This reverts commit 1505e0b789.
pull/1301/head
Karl Hobley 2015-05-18 10:18:36 +01:00
rodzic 4bb016cf75
commit cc2686f398
1 zmienionych plików z 7 dodań i 5 usunięć

Wyświetl plik

@ -6,18 +6,20 @@ from wagtail.utils.compat import render_to_string
def render_modal_workflow(request, html_template, js_template, template_vars=None): def render_modal_workflow(request, html_template, js_template, template_vars=None):
""" """"
Render a response consisting of an HTML chunk and a JS onload chunk Render a response consisting of an HTML chunk and a JS onload chunk
in the format required by the modal-workflow framework. in the format required by the modal-workflow framework.
""" """
response_keyvars = {} response_keyvars = []
if html_template: if html_template:
html = render_to_string(html_template, template_vars or {}, request=request) html = render_to_string(html_template, template_vars or {}, request=request)
response_keyvars['html'] = html response_keyvars.append("'html': %s" % json.dumps(html))
if js_template: if js_template:
js = render_to_string(js_template, template_vars or {}, request=request) js = render_to_string(js_template, template_vars or {}, request=request)
response_keyvars['onload'] = js response_keyvars.append("'onload': %s" % js)
return HttpResponse(json.dumps(response_keyvars), content_type="application/json") response_text = "{%s}" % ','.join(response_keyvars)
return HttpResponse(response_text, content_type="text/javascript")