diff options
Diffstat (limited to 'qc_app')
-rw-r--r-- | qc_app/dbinsert.py | 16 | ||||
-rw-r--r-- | qc_app/templates/select_dataset.html | 43 |
2 files changed, 46 insertions, 13 deletions
diff --git a/qc_app/dbinsert.py b/qc_app/dbinsert.py index 4711262..ab1c350 100644 --- a/qc_app/dbinsert.py +++ b/qc_app/dbinsert.py @@ -255,10 +255,8 @@ def select_dataset(): studyid = form["studyid"] datasets = datasets_by_study(studyid) return render_template( - "select_dataset.html", filename=form["filename"], - filetype=form["filetype"], totallines=form["totallines"], - species=form["species"], genechipid=form["genechipid"], - studyid=studyid, datasets=datasets, avgmethods=averaging_methods(), + "select_dataset.html", **{**form, "studyid": studyid}, + datasets=datasets, avgmethods=averaging_methods(), datascales=dataset_datascales()) except AssertionError as aserr: return render_error(f"Missing data: {aserr.args[0]}") @@ -283,11 +281,19 @@ def create_dataset(): with database_connection() as conn: with conn.cursor(cursorclass=DictCursor) as cursor: + datasetname = form["datasetname"] + cursor.execute("SELECT * FROM ProbeSetFreeze WHERE Name=%s", + (datasetname,)) + results = cursor.fetchall() + if bool(results): + flash("A dataset with that name already exists.", + "alert-error") + return redirect(url_for("dbinsert.select_dataset"), code=307) cursor.execute("SELECT MAX(Id) AS last_id FROM ProbeSetFreeze") new_datasetid = cursor.fetchone()["last_id"] + 1 values = ( new_datasetid, form["studyid"], form["avgid"], - form.get("datasetname",""), form["datasetname2"], + datasetname, form["datasetname2"], form["datasetfullname"], form["datasetshortname"], datetime.now().date().strftime("%Y-%m-%d"), form["datasetpublic"], form["datasetconfidentiality"], diff --git a/qc_app/templates/select_dataset.html b/qc_app/templates/select_dataset.html index a21957d..cad6621 100644 --- a/qc_app/templates/select_dataset.html +++ b/qc_app/templates/select_dataset.html @@ -66,7 +66,10 @@ <select id="avgid" name="avgid" required="required" class="form-col-2"> <option value="">Select averaging method</option> {%for method in avgmethods:%} - <option value="{{method['AvgMethodId']}}"> + <option value="{{method['AvgMethodId']}}" + {%if avgid is defined and method['AvgMethodId'] | int == avgid | int%} + selected="selected" + {%endif%}> {{method["Name"]}} </option> {%endfor%} @@ -76,38 +79,60 @@ <fieldset> <label for="datasetname" class="form-col-1">name:</label> <input id="datasetname" name="datasetname" type="text" - class="form-col-2" /> + class="form-col-2" + {%if datasetname is defined %} + value="{{datasetname}}" + {%endif%} /> </fieldset> <fieldset> <label for="datasetname2" class="form-col-1">name 2:</label> <input id="datasetname2" name="datasetname2" type="text" - required="required" class="form-col-2" /> + required="required" class="form-col-2" + {%if datasetname2 is defined %} + value="{{datasetname2}}" + {%endif%} /> </fieldset> <fieldset> <label for="datasetfullname" class="form-col-1">full name:</label> <input id="datasetfullname" name="datasetfullname" type="text" - required="required" class="form-col-2" /> + required="required" class="form-col-2" + {%if datasetfullname is defined %} + value="{{datasetfullname}}" + {%endif%} /> </fieldset> <fieldset> <label for="datasetshortname" class="form-col-1">short name:</label> <input id="datasetshortname" name="datasetshortname" type="text" - required="required" class="form-col-2" /> + required="required" class="form-col-2" + {%if datasetshortname is defined %} + value="{{datasetshortname}}" + {%endif%} /> </fieldset> <fieldset> <label for="datasetpublic" class="form-col-1">public:</label> <input id="datasetpublic" name="datasetpublic" type="number" - required="required" min="0" max="2" value="0" + required="required" min="0" max="2" + {%if datasetpublic is defined %} + value="{{datasetpublic | int}}" + {%else%} + value="0" + {%endif%} class="form-col-2" /> </fieldset> <fieldset> <label for="datasetconfidentiality">confidentiality:</label> <input id="datasetconfidentiality" name="datasetconfidentiality" - type="number" required="required" min="0" max="2" value="0" + type="number" required="required" min="0" max="2" + {%if datasetconfidentiality is defined %} + value="{{datasetconfidentiality | int}}" + {%else%} + value="0" + {%endif%} class="form-col-2" /> </fieldset> @@ -117,7 +142,9 @@ <option value="">None</option> {%for dscale in datascales:%} <option value="{{dscale}}" - {%if dscale == "log2":%} + {%if datasetdatascale is defined and dscale == datasetdatascale%} + selected="selected" + {%elif dscale == "log2":%} selected="selected" {%endif%}> {{dscale}} |