aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-04-19 16:15:53 +0300
committerFrederick Muriuki Muriithi2023-04-19 16:15:53 +0300
commite72ee8b00d0e2d0456f05160916211a1536054c8 (patch)
treeb8eb5f783e97c57b3dc0372f0fac0179ff896aa0 /wqflask
parent5250d21b878497a71a1a4f9c92fdf490a62a2680 (diff)
downloadgenenetwork2-e72ee8b00d0e2d0456f05160916211a1536054c8.tar.gz
oauth2: Link the data
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/oauth2/data.py27
-rw-r--r--wqflask/wqflask/templates/oauth2/data-list-phenotype.html4
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>