From c9e27583997dfb9ad99914ca7609b44e513c14b7 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Thu, 28 Oct 2021 13:28:51 +0300 Subject: Move "get_sample_data_as_csv" to metadata_edits.py --- wqflask/wqflask/metadata_edits.py | 17 ++++++++++++++++- wqflask/wqflask/views.py | 16 ---------------- 2 files changed, 16 insertions(+), 17 deletions(-) (limited to 'wqflask') 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("//traits//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//sampledata/") -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(): -- cgit v1.2.3