diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/oauth2/data.py | 27 | ||||
-rw-r--r-- | wqflask/wqflask/templates/oauth2/data-list-phenotype.html | 4 |
2 files changed, 30 insertions, 1 deletions
diff --git a/wqflask/wqflask/oauth2/data.py b/wqflask/wqflask/oauth2/data.py index d7be85f0..68a98d98 100644 --- a/wqflask/wqflask/oauth2/data.py +++ b/wqflask/wqflask/oauth2/data.py @@ -283,6 +283,7 @@ def link_mrna_data(): species_name=form["species_name"], dataset_type="mrna")) def __link_error__(err): + error = process_error(err) flash(f"{err['error']}: {err['error_description']}", "alert-danger") return link_source_url @@ -296,3 +297,29 @@ def link_mrna_data(): "selected": tuple(json.loads(dataset) for dataset in form.getlist("selected")) }).either(lambda err: __link_error__(process_error(err)), __link_success__) + +@data.route("/link/phenotype", methods=["POST"]) +def link_phenotype_data(): + """Link phenotype data to a group.""" + form = request.form + link_source_url = redirect(url_for("oauth2.data.list_data")) + if bool(form.get("species_name")): + link_source_url = redirect(url_for( + "oauth2.data.list_data_by_species_and_dataset", + species_name=form["species_name"], dataset_type="mrna")) + + def __link_error__(err): + error = process_error(err) + flash(f"{error['error']}: {error['error_description']}", "alert-danger") + return link_source_url + + def __link_success__(success): + flash(success["description"], "alert-success") + return link_source_url + + return oauth2_post("oauth2/data/link/phenotype", json={ + "species_name": form.get("species_name"), + "group_id": form.get("group_id"), + "selected": tuple( + json.loads(trait) for trait in form.getlist("selected"))}).either( + __link_error__, __link_success__) diff --git a/wqflask/wqflask/templates/oauth2/data-list-phenotype.html b/wqflask/wqflask/templates/oauth2/data-list-phenotype.html index 8329e023..b79b3096 100644 --- a/wqflask/wqflask/templates/oauth2/data-list-phenotype.html +++ b/wqflask/wqflask/templates/oauth2/data-list-phenotype.html @@ -24,7 +24,9 @@ </div> <div class="row"> - <form id="frm-link-phenotypes"> + <form id="frm-link-phenotypes" + action="{{url_for('oauth2.data.link_phenotype_data')}}" + method="POST"> <legend style="text-transform: capitalize;"> {{dataset_type}}: Link Traits to Group </legend> |