mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-19 04:31:11 +00:00
Fixes to render_modal_workflow
- RequestContext is deprecated - Fixed mutable dict as a default parameter
This commit is contained in:
parent
87cd93587e
commit
4ad856d0d8
1 changed files with 3 additions and 5 deletions
|
|
@ -1,24 +1,22 @@
|
|||
import json
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.template import RequestContext
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
||||
def render_modal_workflow(request, html_template, js_template, template_vars={}):
|
||||
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 = []
|
||||
context = RequestContext(request)
|
||||
|
||||
if html_template:
|
||||
html = render_to_string(html_template, template_vars, context)
|
||||
html = render_to_string(html_template, template_vars or {}, request=request)
|
||||
response_keyvars.append("'html': %s" % json.dumps(html))
|
||||
|
||||
if js_template:
|
||||
js = render_to_string(js_template, template_vars, context)
|
||||
js = render_to_string(js_template, template_vars or {}, request=request)
|
||||
response_keyvars.append("'onload': %s" % js)
|
||||
|
||||
response_text = "{%s}" % ','.join(response_keyvars)
|
||||
|
|
|
|||
Loading…
Reference in a new issue