aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2021-05-25 13:19:14 +0300
committerBonfaceKilz2021-05-26 20:01:28 +0300
commit7d3edb7ce668df5d072ed87a755f61782bb30a82 (patch)
treed0b227f0209db8e9bb0b312fb04d14c2da4d20e9
parent01d742d4dd5ee9d193e1c0ccb3d32ec9592c099f (diff)
downloadgenenetwork2-7d3edb7ce668df5d072ed87a755f61782bb30a82.tar.gz
wqflask: views: Add method that updates the trait
* wqflask/wqflask/views.py (update_trait): New function.
-rw-r--r--wqflask/wqflask/views.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 9936f65c..cd77f64f 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -27,6 +27,7 @@ from gn3.db.phenotypes import Phenotype
from gn3.db.phenotypes import PublishXRef
from gn3.db.phenotypes import Publication
from gn3.db.phenotypes import fetchone
+from gn3.db.phenotypes import update
from flask import current_app
from flask import g
@@ -447,6 +448,49 @@ def edit_trait(name, inbred_set_id):
version=GN_VERSION)
+@app.route("/trait/update", methods=["POST"])
+def update_trait():
+ 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"))
+ # Filter out empty values
+ data_ = {k: v for k, v in request.form.items() if v is not ''}
+
+ # Run updates:
+ update(conn, "Phenotype",
+ data=Phenotype(
+ pre_pub_description=data_.get("pre-pub-desc"),
+ post_pub_description=data_.get("post-pub-desc"),
+ original_description=data_.get("orig-desc"),
+ units=data_.get("units"),
+ pre_pub_abbreviation=data_.get("pre-pub-abbrev"),
+ post_pub_abbreviation=data_.get("post-pub-abbrev"),
+ lab_code=data_.get("labcode"),
+ submitter=data_.get("submitter"),
+ owner=data_.get("owner"),
+ ),
+ where=Phenotype(id_=data_.get("phenotype-id")))
+ update(conn, "Publication",
+ data=Publication(
+ abstract=data_.get("abstract"),
+ authors=data_.get("authors"),
+ title=data_.get("title"),
+ journal=data_.get("journal"),
+ volume=data_.get("volume"),
+ pages=data_.get("pages"),
+ month=data_.get("month"),
+ year=data_.get("year")),
+ where=Publication(id_=data_.get("pubmed-id")))
+ update(conn, "PublishXRef",
+ data=PublishXRef(comments="",
+ publication_id=data_.get("pubmed-id")),
+ where=PublishXRef(
+ id_=data_.get("dataset-name"),
+ inbred_set_id=data_.get("inbred-set-id")))
+ return redirect("/trait/10007/edit/1")
+
+
@app.route("/create_temp_trait", methods=('POST',))
def create_temp_trait():
logger.info(request.url)