Пример #1
0
def pchempropBatchOutputPage(request, model="", header="P-Chem Properties", formData=None):

    # get all the fields from the form in the request, then
    # instantiate model object to get checkedCalcsAndProps dict.
    # render said dict into cts_pchemprop_ajax_calls template

    from cts_app.models.pchemprop import pchemprop_output
    from django.utils.safestring import mark_safe

    pchemprop_obj = pchemprop_output.pchempropOutputPage(request)
    batch_chemicals = request.POST.get("nodes")  # expecting list of nodes (change name??)

    if not batch_chemicals:
        batch_chemicals = []

    html = render_to_string("cts_downloads.html", {"run_data": mark_safe(json.dumps(pchemprop_obj.run_data))})

    html += '<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">'

    # for pchemprop batch, use p-chem for selecting inputs for batch data:
    html += render_to_string(
        "cts_pchemprop_requests.html",
        {
            "checkedCalcsAndProps": mark_safe(pchemprop_obj.checkedCalcsAndPropsDict),
            "kow_ph": pchemprop_obj.kow_ph,
            "speciation_inputs": "null",
            "nodes": mark_safe(batch_chemicals),
            "nodejs_host": settings.NODEJS_HOST,
            "nodejs_port": settings.NODEJS_PORT,
        },
    )

    html += render_to_string("cts_gentrans_tree.html", {"gen_max": 0})

    # what about other places cts_pchemprop_ajax_calls is rendered WITHOUT "nodes"???

    # display content on the output page:
    # html += '<div id="batch_csv_wrap" hidden></div>'

    return html