diff options
author | Frederick Muriuki Muriithi | 2023-08-30 09:28:58 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-10-26 05:00:30 +0300 |
commit | b00a4e42e9f4b0b857c100812ea4d30b32f738cb (patch) | |
tree | ede562b7f7d333f3c2c1c3c0cccbdf922af387e9 /wqflask | |
parent | bb1c01340ab6e05d7e468ea0b40af43f1c52cc59 (diff) | |
download | genenetwork2-b00a4e42e9f4b0b857c100812ea4d30b32f738cb.tar.gz |
Call utils to replace unnecessary functions.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/oauth2/request_utils.py | 4 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 17 |
2 files changed, 8 insertions, 13 deletions
diff --git a/wqflask/wqflask/oauth2/request_utils.py b/wqflask/wqflask/oauth2/request_utils.py index 2f475337..7d2ec539 100644 --- a/wqflask/wqflask/oauth2/request_utils.py +++ b/wqflask/wqflask/oauth2/request_utils.py @@ -86,7 +86,9 @@ def flash_success(success): def with_flash_error(response) -> Callable: def __err__(err) -> Response: error = process_error(err) - flash(f"{error['error']}: {error['error_description']}", "alert-danger") + flash(f"{error['status_code']} {error['error']}: " + f"{error['error_description']}", + "alert-danger") return response return __err__ diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 11328238..30d0f872 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -81,7 +81,7 @@ from wqflask.db_info import InfoPage from wqflask.oauth2 import client from wqflask.oauth2.client import no_token_get -from wqflask.oauth2.request_utils import with_flash_error +from wqflask.oauth2.request_utils import with_flash_error, with_flash_success from utility import temp_data from utility.tools import get_setting @@ -1177,22 +1177,15 @@ def edit_case_attributes(inbredset_id: int) -> Response: } } - def __edit_fail__(error): - err = process_error(error) - flash(f"{err['error']}: {err['error_description']}", "alert-danger") - return redirect(url_for( - "edit_case_attributes", inbredset_id=inbredset_id)) - - def __edit_success__(result): - flash({result["message"]}, "alert-success") - return redirect(url_for( - "edit_case_attributes", inbredset_id=inbredset_id)) + edit_case_attributes_page = redirect(url_for( + "edit_case_attributes", inbredset_id=inbredset_id)) return client.post( f"case-attribute/{inbredset_id}/edit", json={ "edit-data": reduce(__process_data__, form.items(), {}) }).either( - __edit_fail__, __edit_success__) + with_flash_error(edit_case_attributes_page), + with_flash_success(edit_case_attributes_page)) def __fetch_strains__(inbredset_group): return client.get(f"case-attribute/{inbredset_id}/strains").then( |