From 6e77937653e6ed478c138ecf47ca537f27013c68 Mon Sep 17 00:00:00 2001 From: Martin Van der Linden Date: Thu, 14 Nov 2024 12:11:31 -0500 Subject: [PATCH] Add SAFE_DEV_MODE env that disables post requests to API (#175) * Update display_callbacks.py * Handle through config * Bug fix --- app/callbacks/display_callbacks.py | 3 +++ app/config.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/callbacks/display_callbacks.py b/app/callbacks/display_callbacks.py index c12ddda..005cc24 100644 --- a/app/callbacks/display_callbacks.py +++ b/app/callbacks/display_callbacks.py @@ -493,6 +493,9 @@ def acknowledge_event(n_clicks, event_id_on_display, user_headers, user_credenti if event_id_on_display == 0 or n_clicks == 0: raise PreventUpdate + if cfg.SAFE_DEV_MODE == "True": + raise PreventUpdate + user_token = user_headers["Authorization"].split(" ")[1] api_client.token = user_token call_api(api_client.acknowledge_event, user_credentials)(event_id=int(event_id_on_display)) diff --git a/app/config.py b/app/config.py index 1d2576b..27d30f1 100644 --- a/app/config.py +++ b/app/config.py @@ -23,6 +23,9 @@ SENTRY_DSN: Optional[str] = os.getenv("SENTRY_DSN") SERVER_NAME: Optional[str] = os.getenv("SERVER_NAME") +# Safeguards +SAFE_DEV_MODE: Optional[str] = os.getenv("SAFE_DEV_MODE") + # App config variables MAX_ALERTS_PER_EVENT = 10 CAM_OPENING_ANGLE = 87