From b19fb558a3cfc1b0d82eeeef52b99dab181472cb Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Tue, 9 Apr 2024 14:36:50 +0200 Subject: [PATCH 1/3] Made BRO portal demo/production configurable --- brostar_api/settings.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/brostar_api/settings.py b/brostar_api/settings.py index 122fa69..e1a1296 100644 --- a/brostar_api/settings.py +++ b/brostar_api/settings.py @@ -20,10 +20,11 @@ DATABASE_USER = os.getenv("DATABASE_USER", "brostar") DATABASE_PASSWORD = os.getenv("DATABASE_PASSWORD", "brostar") SENTRY_DSN = os.getenv("SENTRY_DSN") # Not required, only used in staging/production. +USE_BRO_PRODUCTION_ENV = os.getenv("USE_BRO_PRODUCTION", default="false") # Convert the environment variable (which is a string) to a boolean. -DEBUG = DEBUG_ENV.lower() == "true" # True is the default - +DEBUG = DEBUG_ENV.lower() == "true" # default: True +USE_BRO_PRODUCTION = USE_BRO_PRODUCTION_ENV.lower() == "true" # Default: False TIME_ZONE = "CET" USE_TZ = True @@ -214,15 +215,9 @@ # SENTRY_DSN will only be set on staging/production, btw. sentry_sdk.init(dsn=SENTRY_DSN) -# BRO SETTINGS: -# TODO: voor nu is het hardcoded op True. We zouden het zo moeten inrichten dat -# de staging standaard op demo staat en productie op de BRO productie omgeving -BRO_DEMO_OMGEVING = True - -if BRO_DEMO_OMGEVING: - BRO_UITGIFTE_SERVICE_URL = "https://int-publiek.broservices.nl" - BRONHOUDERSPORTAAL_URL = "https://demo.bronhouderportaal-bro.nl" -else: +if USE_BRO_PRODUCTION: BRO_UITGIFTE_SERVICE_URL = "https://publiek.broservices.nl" BRONHOUDERSPORTAAL_URL = "https://bronhouderportaal-bro.nl" - # BRONHOUDERSPORTAAL_URL = "https://www.bronhouderportaal-bro.nl" +else: + BRO_UITGIFTE_SERVICE_URL = "https://int-publiek.broservices.nl" + BRONHOUDERSPORTAAL_URL = "https://demo.bronhouderportaal-bro.nl" From f80a5854932d4524c8b2d58d4b0b431bf5538ac2 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Tue, 9 Apr 2024 14:38:42 +0200 Subject: [PATCH 2/3] Updated changelog --- CHANGES.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a74d16f..903a53b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,8 +2,7 @@ ## 0.2 (unreleased) - -- Nothing changed yet. +- Made BRO portal (demo/production) configurable. The default is to use the demo portal, of course. Set `USE_BRO_PRODUCTION` environment variable to `true` for production. ## 0.1 (2024-04-09) From d573e9fe0bdafbcb3f26ce5ee6dbc24a5adb1129 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Tue, 9 Apr 2024 14:42:43 +0200 Subject: [PATCH 3/3] Made intermediary variables more clear by lowercasing them --- brostar_api/settings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/brostar_api/settings.py b/brostar_api/settings.py index e1a1296..0267f03 100644 --- a/brostar_api/settings.py +++ b/brostar_api/settings.py @@ -15,16 +15,17 @@ NENS_AUTH_ISSUER = os.getenv("NENS_AUTH_ISSUER") NENS_AUTH_CLIENT_ID = os.getenv("NENS_AUTH_CLIENT_ID") NENS_AUTH_CLIENT_SECRET = os.getenv("NENS_AUTH_CLIENT_SECRET") -DEBUG_ENV = os.getenv("DEBUG", default="true") +_debug_env = os.getenv("DEBUG", default="true") DATABASE_HOST = os.getenv("DATABASE_HOST", "db") DATABASE_USER = os.getenv("DATABASE_USER", "brostar") DATABASE_PASSWORD = os.getenv("DATABASE_PASSWORD", "brostar") SENTRY_DSN = os.getenv("SENTRY_DSN") # Not required, only used in staging/production. -USE_BRO_PRODUCTION_ENV = os.getenv("USE_BRO_PRODUCTION", default="false") +_use_bro_production_env = os.getenv("USE_BRO_PRODUCTION", default="false") + +# Convert string-based environment variables to booleans. +DEBUG = _debug_env.lower() == "true" # default: True +USE_BRO_PRODUCTION = _use_bro_production_env.lower() == "true" # Default: False -# Convert the environment variable (which is a string) to a boolean. -DEBUG = DEBUG_ENV.lower() == "true" # default: True -USE_BRO_PRODUCTION = USE_BRO_PRODUCTION_ENV.lower() == "true" # Default: False TIME_ZONE = "CET" USE_TZ = True @@ -32,7 +33,6 @@ # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent - ALLOWED_HOSTS = ["localhost", "127.0.0.1", "0.0.0.0"] if not DEBUG: