aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qc_app/templates/rqtl2/select-population.html3
-rw-r--r--qc_app/upload/rqtl2.py41
2 files changed, 31 insertions, 13 deletions
diff --git a/qc_app/templates/rqtl2/select-population.html b/qc_app/templates/rqtl2/select-population.html
index 3ce9dc8..a1e2a83 100644
--- a/qc_app/templates/rqtl2/select-population.html
+++ b/qc_app/templates/rqtl2/select-population.html
@@ -16,7 +16,8 @@
organised by.</p>
</div>
-<form method="POST" action="{{url_for('samples.select_population')}}">
+<form method="POST"
+ action="{{url_for('upload.rqtl2.select_population', species_id=species.SpeciesId)}}">
<legend class="heading">select grouping/population</legend>
{{flash_messages("error-select-population")}}
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"