aboutsummaryrefslogtreecommitdiff
path: root/qc_app/dbinsert.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/dbinsert.py')
-rw-r--r--qc_app/dbinsert.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/qc_app/dbinsert.py b/qc_app/dbinsert.py
index 4fbd0d3..523152d 100644
--- a/qc_app/dbinsert.py
+++ b/qc_app/dbinsert.py
@@ -177,6 +177,17 @@ def create_study():
flash(f"Missing data: {aserr.args[0]}", "alert-error")
return redirect(url_for("dbinsert.select_study"), code=307)
+def datasets_by_study(studyid:int) -> tuple:
+ "Retrieve datasets associated with a study with the ID `studyid`."
+ with database_connection() as conn:
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ query = "SELECT * FROM ProbeSetFreeze WHERE ProbeFreezeId=%s"
+ print(f"QUERY: {query}\n\tPARAMS: ({studyid},)")
+ cursor.execute(query, (studyid,))
+ return tuple(cursor.fetchall())
+
+ return tuple()
+
@dbinsertbp.route("/dataset", methods=["POST"])
def select_dataset():
"Select the dataset to add the file contents against"
@@ -186,15 +197,14 @@ def select_dataset():
assert form.get("filetype"), "filetype"
assert form.get("species"), "species"
assert form.get("genechipid"), "platform"
- assert (form.get("studyid") or form.get(studyname)), ""
- assert form.get(""), ""
- assert form.get(""), ""
- assert form.get(""), ""
- assert form.get(""), ""
+ assert (form.get("studyid") or request.args.get("studyid")), "study"
+ studyid=(form.get("studyid") or request.args.get("studyid"))
+ datasets = datasets_by_study(studyid)
return render_template(
"select_dataset.html", filename=form["filename"],
- filetype=form["filetype"], species=speciesid, genechipid=genechipid)
+ filetype=form["filetype"], species=form["species"],
+ genechipid=form["genechipid"], studyid=studyid, datasets=datasets)
except AssertionError as aserr:
return render_error(f"Missing data: {aserr.args[0]}")