Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
wagtail_gardentronic / wagtail / admin / modal_workflow.py
Size: Mime:
from django.http import JsonResponse
from django.template.loader import render_to_string


def render_modal_workflow(request, html_template, js_template=None, template_vars=None, json_data=None):
    """"
    Render a response consisting of an HTML chunk and a JS onload chunk
    in the format required by the modal-workflow framework.
    """
    if js_template:
        raise TypeError("Passing a js_template argument to render_modal_workflow is no longer supported")

    # construct response as JSON
    response = {}

    if html_template:
        response['html'] = render_to_string(html_template, template_vars or {}, request=request)

    if json_data:
        response.update(json_data)

    return JsonResponse(response)