aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2024-07-30 20:56:14 +0000
committerAlexander_Kabui2024-08-28 15:02:46 +0300
commita1eb080eca9611262f1a3fa4463d40653d6899c2 (patch)
tree0827780060c0103684746f6b0bca53dd8c30d2c0
parent89e321120b6c43188fe7b1d3da205caefab06406 (diff)
downloadgenenetwork2-a1eb080eca9611262f1a3fa4463d40653d6899c2.tar.gz
Fix GN3 URIs for case attribute editing
Also improve error logging somewhat (but still need to properly display the error in a template)
-rw-r--r--gn2/wqflask/views.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index 152a1be6..9c1f7685 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -1362,7 +1362,7 @@ def edit_case_attributes(inbredset_id: int) -> Response:
return monad_requests.post(
urljoin(
current_app.config["GN_SERVER_URL"],
- f"/api/case-attribute/{inbredset_id}/edit"),
+ f"case-attribute/{inbredset_id}/edit"),
json={
"edit-data": reduce(__process_data__, form.items(), {})
},
@@ -1374,29 +1374,33 @@ def edit_case_attributes(inbredset_id: int) -> Response:
def __fetch_strains__(inbredset_group):
return monad_requests.get(urljoin(
current_app.config["GN_SERVER_URL"],
- f"/api/case-attribute/{inbredset_id}/strains")).then(
+ f"case-attribute/{inbredset_id}/strains")).then(
lambda resp: {**inbredset_group, "strains": resp.json()})
def __fetch_names__(strains):
return monad_requests.get(urljoin(
current_app.config["GN_SERVER_URL"],
- f"/api/case-attribute/{inbredset_id}/names")).then(
+ f"case-attribute/{inbredset_id}/names")).then(
lambda resp: {**strains, "case_attribute_names": resp.json()})
def __fetch_values__(canames):
return monad_requests.get(urljoin(
current_app.config["GN_SERVER_URL"],
- f"/api/case-attribute/{inbredset_id}/values")).then(
+ f"case-attribute/{inbredset_id}/values")).then(
lambda resp: {**canames, "case_attribute_values": {
value["StrainName"]: value for value in resp.json()}})
+ def __view_error__(err):
+ current_app.logger.error("%s", err)
+ return "We experienced an error"
+
return monad_requests.get(urljoin(
current_app.config["GN_SERVER_URL"],
- f"/api/case-attribute/{inbredset_id}")).then(
+ f"case-attribute/{inbredset_id}")).then(
lambda resp: {"inbredset_group": resp.json()}).then(
__fetch_strains__).then(__fetch_names__).then(
__fetch_values__).either(
- lambda err: err, # TODO: Handle error better
+ __view_error__,
lambda values: render_template(
"edit_case_attributes.html", inbredset_id=inbredset_id, **values))