diff options
-rw-r--r-- | wqflask/wqflask/metadata_edits.py | 17 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 16 |
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(): |