mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Tidy up render_modal_workflow
This commit is contained in:
parent
c7f2837ad8
commit
1505e0b789
@ -6,20 +6,18 @@ from wagtail.utils.compat import render_to_string
|
||||
|
||||
|
||||
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
|
||||
in the format required by the modal-workflow framework.
|
||||
"""
|
||||
response_keyvars = []
|
||||
response_keyvars = {}
|
||||
|
||||
if html_template:
|
||||
html = render_to_string(html_template, template_vars or {}, request=request)
|
||||
response_keyvars.append("'html': %s" % json.dumps(html))
|
||||
response_keyvars['html'] = html
|
||||
|
||||
if js_template:
|
||||
js = render_to_string(js_template, template_vars or {}, request=request)
|
||||
response_keyvars.append("'onload': %s" % js)
|
||||
response_keyvars['onload'] = js
|
||||
|
||||
response_text = "{%s}" % ','.join(response_keyvars)
|
||||
|
||||
return HttpResponse(response_text, content_type="text/javascript")
|
||||
return HttpResponse(json.dumps(response_keyvars), content_type="application/json")
|
||||
|
Loading…
Reference in New Issue
Block a user