From 2de0bdc7c3350dacf14218bb1a1e4721ac4d1237 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Thu, 20 May 2021 23:22:49 +0300 Subject: wqflask: views: Add extra endpoint to display individual trait edit * wqflask/wqflask/views.py (show_edit_trait_page): New function/ end-point. --- wqflask/wqflask/views.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 4834ee63..51266ada 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -21,6 +21,7 @@ import base64 import array import sqlalchemy from wqflask import app +from flask import current_app from flask import g from flask import Response from flask import request @@ -414,13 +415,35 @@ def submit_trait_form(): version=GN_VERSION) -@app.route("/edit_trait_form") -def edit_trait_page(): - species_and_groups = get_species_groups() +@app.route("/trait//edit/") +def show_edit_trait_page(name, inbred_set_id): + from gn3.db.phenotypes import (Phenotype, + PublishXRef, + Publication, + fetchone) + import MySQLdb + 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")) + publish_xref = fetchone( + conn=conn, + table="PublishXRef", + where=PublishXRef(id_=name, + inbred_set_id=inbred_set_id)) + phenotype_ = fetchone( + conn=conn, + table="Phenotype", + where=Phenotype(id_=publish_xref.phenotype_id)) + publication_ = fetchone( + conn=conn, + table="Publication", + where=Publication(id_=publish_xref.publication_id)) return render_template( "edit_trait.html", - species_and_groups=species_and_groups, - gn_server_url=GN_SERVER_URL, + publish_xref=publish_xref, + phenotype=phenotype_, + publication=publication_, version=GN_VERSION) -- cgit v1.2.3