示例#1
0
def molecule_detail(request, molecule):
    job_form = JobForm.get_form(request, molecule)
    mol_form = MoleculeForm(request.REQUEST)

    job_is_valid = job_form.is_valid(request.method)
    mol_is_valid = mol_form.is_valid()

    if job_is_valid and mol_is_valid:
        return job_form.get_results(request, molecule, mol_form)
    elif request.is_ajax():
        job_form_html = render_crispy_form(
            job_form, context=RequestContext(request))
        mol_form_html = render_crispy_form(
            mol_form, context=RequestContext(request))
        a = {
            "success": False,
            "job_form_html": job_form_html,
            "mol_form_html": mol_form_html,
        }
        return HttpResponse(json.dumps(a), content_type="application/json")

    a = get_molecule_info_status(molecule)
    a["job_form"] = job_form
    a["mol_form"] = MoleculeForm()
    return render(request, "chem/molecule_detail.html", a)
示例#2
0
 def test_get_molecule_info(self):
     name = "24a_TON"
     results = utils.get_molecule_info_status(name)
     del results["features"]
     del results["property_predictions"]
     expected = {
         'molecule': '24a_TON',
         # 'property_predictions': (
         #     ("H**O", "h**o", "eV", -5.6866366091077571),
         #     ("LUMO", "lumo", "eV", -2.1298787902985779),
         #     ("Band Gap", "gap", "eV", 3.4415766653971942),
         # ),
         'exact_name': '24aaA_TON_A_A_n1_m1_x1_y1_z1',
         'property_limits': {
             'm': [
                 -5.5380175794413322,
                 -2.3145802963818163,
                 2.9191909229300554],
             'n': [
                 -5.74066757207639,
                 -2.9489392195479147,
                 2.5846925036411794]
         },
         'error_report': None,
         'name_error': None,
         'datapoints': [],
         'new': True,
         'exact_name_spacers': '2**4aaA**_TON_A**_A**_n1_m1_x1_y1_z1',
         'structure_type': 'Benzobisazole',
     }
     self.assertEqual(results, expected)
示例#3
0
def molecule_detail(request, molecule):
    job_form = JobForm.get_form(request, molecule)
    mol_form = MoleculeForm(request.REQUEST)

    job_is_valid = job_form.is_valid(request.method)
    mol_is_valid = mol_form.is_valid()

    if job_is_valid and mol_is_valid:
        return job_form.get_results(request, molecule, mol_form)
    elif request.is_ajax():
        job_form_html = render_crispy_form(job_form,
                                           context=RequestContext(request))
        mol_form_html = render_crispy_form(mol_form,
                                           context=RequestContext(request))
        a = {
            "success": False,
            "job_form_html": job_form_html,
            "mol_form_html": mol_form_html,
        }
        return HttpResponse(json.dumps(a), content_type="application/json")

    a = get_molecule_info_status(molecule)
    a["job_form"] = job_form
    a["mol_form"] = MoleculeForm()
    return render(request, "chem/molecule_detail.html", a)
示例#4
0
def molecule_detail_json(request, molecule):
    if request.REQUEST.get("geometry"):
        mol, _, _, _ = get_molecule_status(molecule)
        a = mol.get_json()
    else:
        a = get_molecule_info_status(molecule)
    return HttpResponse(json.dumps(a, cls=DjangoJSONEncoder),
                        content_type="application/json")
示例#5
0
def molecule_detail_json(request, molecule):
    if request.REQUEST.get("geometry"):
        mol, _, _, _ = get_molecule_status(molecule)
        a = mol.get_json()
    else:
        a = get_molecule_info_status(molecule)
    return HttpResponse(json.dumps(a, cls=DjangoJSONEncoder),
                        content_type="application/json")