aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2021-10-28 13:28:51 +0300
committerBonfaceKilz2021-11-04 15:22:41 +0300
commitc9e27583997dfb9ad99914ca7609b44e513c14b7 (patch)
tree8038aa78ae16bcfa450b59ec1f9880e7c355f675 /wqflask
parent28f67d85416c48c2196dff889bfab8e9659aa5b6 (diff)
downloadgenenetwork2-c9e27583997dfb9ad99914ca7609b44e513c14b7.tar.gz
Move "get_sample_data_as_csv" to metadata_edits.py
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/metadata_edits.py17
-rw-r--r--wqflask/wqflask/views.py16
2 files changed, 16 insertions, 17 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py
index fad9c315..85f45592 100644
--- a/wqflask/wqflask/metadata_edits.py
+++ b/wqflask/wqflask/metadata_edits.py
@@ -7,7 +7,7 @@ import difflib
from collections import namedtuple
from flask import (Blueprint, current_app, redirect,
- flash, g, render_template, request)
+ flash, g, render_template, request, Response)
from itertools import groupby
from wqflask.decorators import edit_access_required
@@ -343,3 +343,18 @@ def update_probeset(name: str):
return redirect(f"/datasets/traits/{name}"
f"?resource-id={request.args.get('resource-id')}")
+
+@metadata_edit.route("/<dataset_id>/traits/<phenotype_id>/csv")
+def get_sample_data_as_csv(dataset_id: str, phenotype_id: int):
+ return Response(
+ get_trait_csv_sample_data(
+ conn=MySQLdb.Connect(db=current_app.config.get("DB_NAME"),
+ user=current_app.config.get("DB_USER"),
+ passwd=current_app.config.get("DB_PASS"),
+ host=current_app.config.get("DB_HOST")),
+ trait_name=str(dataset_id),
+ phenotype_id=str(phenotype_id)),
+ mimetype="text/csv",
+ headers={"Content-disposition":
+ "attachment; filename=myplot.csv"}
+ )
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 3a84141d..3e53e4c5 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -1055,22 +1055,6 @@ def json_default_handler(obj):
type(obj), repr(obj)))
-@app.route("/trait/<trait_name>/sampledata/<phenotype_id>")
-def get_sample_data_as_csv(trait_name: int, phenotype_id: int):
- conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"),
- user=current_app.config.get("DB_USER"),
- passwd=current_app.config.get("DB_PASS"),
- host=current_app.config.get("DB_HOST"))
- csv_ = get_trait_csv_sample_data(conn, str(trait_name),
- str(phenotype_id))
- return Response(
- csv_,
- mimetype="text/csv",
- headers={"Content-disposition":
- "attachment; filename=myplot.csv"}
- )
-
-
@app.route("/admin/data-sample/diffs/")
@edit_access_required
def display_diffs_admin():