about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBonfaceKilz2021-07-06 14:13:43 +0300
committerBonfaceKilz2021-07-12 09:02:16 +0300
commitaf6b141ac37dbc38f990a871e61127d1efde10ce (patch)
tree8459f72bddefe540e08db17922b5971501ef47b3
parentbce7aaab7d65309dc0e755a74bf8339a721f2cd9 (diff)
downloadgenenetwork2-af6b141ac37dbc38f990a871e61127d1efde10ce.tar.gz
wqflask: views: Rename endpoint for editing a trait
* wqflask/wqflask/views.py (edit_trait): Rename to
edit_phenotype. Also rename the endpoint to
"/trait/<name>/edit/inbredset-id/<inbred_set_id>" to indicate that and
inbredset-id is required. This endpoint will be only used for
phenotypes. Finally, render the "edit_phenotype.html" template
(update_trait): Rename to update_phenotype. Also, remove hard-coded
redirect, and replace it with the correct values.

* wqflask/wqflask/templates/edit_trait.html: Rename to
edit_phenotype.html
-rw-r--r--wqflask/wqflask/templates/edit_phenotype.html (renamed from wqflask/wqflask/templates/edit_trait.html)0
-rw-r--r--wqflask/wqflask/views.py11
2 files changed, 6 insertions, 5 deletions
diff --git a/wqflask/wqflask/templates/edit_trait.html b/wqflask/wqflask/templates/edit_phenotype.html
index 7d4c65f8..7d4c65f8 100644
--- a/wqflask/wqflask/templates/edit_trait.html
+++ b/wqflask/wqflask/templates/edit_phenotype.html
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index da427bfe..595a0de7 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -428,9 +428,9 @@ def submit_trait_form():
         version=GN_VERSION)
 
 
-@app.route("/trait/<name>/edit/<inbred_set_id>")
+@app.route("/trait/<name>/edit/inbredset-id/<inbred_set_id>")
 @admin_login_required
-def edit_trait(name, inbred_set_id):
+def edit_phenotype(name, inbred_set_id):
     conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"),
                            user=current_app.config.get("DB_USER"),
                            passwd=current_app.config.get("DB_PASS"),
@@ -476,7 +476,7 @@ def edit_trait(name, inbred_set_id):
     if len(diff_data) > 0:
         diff_data_ = groupby(diff_data, lambda x: x.timestamp)
     return render_template(
-        "edit_trait.html",
+        "edit_phenotype.html",
         diff=diff_data_,
         publish_xref=publish_xref,
         phenotype=phenotype_,
@@ -486,7 +486,7 @@ def edit_trait(name, inbred_set_id):
 
 
 @app.route("/trait/update", methods=["POST"])
-def update_trait():
+def update_phenotype():
     conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"),
                            user=current_app.config.get("DB_USER"),
                            passwd=current_app.config.get("DB_PASS"),
@@ -544,7 +544,8 @@ def update_trait():
                data=MetadataAudit(dataset_id=data_.get("dataset-name"),
                                   editor=author.decode("utf-8"),
                                   json_data=json.dumps(diff_data)))
-    return redirect("/trait/10007/edit/1")
+    return redirect(f"/trait/{data_.get('dataset-name')}"
+                    f"/edit/inbredset-id/{data_.get('inbred-set-id')}")
 
 
 @app.route("/create_temp_trait", methods=('POST',))