diff options
author | zsloan | 2024-07-30 20:56:14 +0000 |
---|---|---|
committer | zsloan | 2024-07-30 20:56:14 +0000 |
commit | e693056b193c9c08bf0a0e99df4352cfeb83de2f (patch) | |
tree | 52312faee695911fd3697ce54ee90291c99202d0 /gn2 | |
parent | 8ce3d96284a3063b19489f73cb23764daec36a71 (diff) | |
download | genenetwork2-e693056b193c9c08bf0a0e99df4352cfeb83de2f.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)
Diffstat (limited to 'gn2')
-rw-r--r-- | gn2/wqflask/views.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index daddb442..a0c3d6a7 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -1370,7 +1370,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(), {}) }, @@ -1382,29 +1382,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)) |