aboutsummaryrefslogtreecommitdiff
path: root/qc_app/upload
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-08 05:09:02 +0300
committerFrederick Muriuki Muriithi2024-01-08 05:52:07 +0300
commitcfe64eb35b6e24b4ca127cba30ecccd465051d1f (patch)
tree58fbe02235779d22fa9bb5ae1a0ee51a59518dd2 /qc_app/upload
parent951c3c2fd343eec4b3743ac313ad6ce49082dda3 (diff)
downloadgn-uploader-cfe64eb35b6e24b4ca127cba30ecccd465051d1f.tar.gz
Implement "POST" path for "select-population" route.
Diffstat (limited to 'qc_app/upload')
-rw-r--r--qc_app/upload/rqtl2.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py
index aabcea9..f27f0bf 100644
--- a/qc_app/upload/rqtl2.py
+++ b/qc_app/upload/rqtl2.py
@@ -6,11 +6,15 @@ from flask import (
url_for,
redirect,
Blueprint,
- render_template)
+ render_template,
+ current_app as app)
from qc_app.dbinsert import species as all_species
-from qc_app.dbinsert import species_by_id, groups_by_species
-from qc_app.db_utils import with_db_connection
+from qc_app.db_utils import with_db_connection, database_connection
+from qc_app.db import (
+ species_by_id,
+ populations_by_species,
+ population_by_species_and_id)
rqtl2 = Blueprint("rqtl2", __name__)
@@ -34,15 +38,28 @@ def select_species():
methods=["GET", "POST"])
def select_population(species_id: int):
"""Select/Create the population to organise data under."""
- species = with_db_connection(lambda conn: species_by_id(conn, species_id))
- if not bool(species):
- flash("Invalid species selected!", "alert-error error-rqtl2")
- return redirect(url_for("upload.rqtl2.select_species"))
+ with database_connection(app.config["SQL_URI"]) as conn:
+ species = species_by_id(conn, species_id)
+ if not bool(species):
+ flash("Invalid species selected!", "alert-error error-rqtl2")
+ return redirect(url_for("upload.rqtl2.select_species"))
- if request.method == "GET":
- return render_template(
- "rqtl2/select-population.html",
- species=species,
- populations=groups_by_species(species_id))
+ if request.method == "GET":
+ return render_template(
+ "rqtl2/select-population.html",
+ species=species,
+ populations=populations_by_species(conn, species_id))
+
+ population = population_by_species_and_id(
+ conn, species["SpeciesId"], request.form.get("inbredset_id"))
+ if not bool(population):
+ flash("Invalid Population!", "alert-error error-rqtl2")
+ return redirect(
+ url_for("upload.rqtl2.select_population", pgsrc="error"),
+ code=307)
+
+ return redirect(url_for("upload.rqtl2.upload_rqtl2_bundle",
+ species_id=species["SpeciesId"],
+ population_id=population["InbredSetId"]))
return "WOULD PROCESS DATA"