From 44eb7374f804c8434125ec0d10e21a43ba60cdc5 Mon Sep 17 00:00:00 2001 From: Michael Collins <15347726+michaeljcollinsuk@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:07:26 +0100 Subject: [PATCH] Feature/add local settings (#242) * Add local setting files Allows us to simplify some settings such as ALLOWED_HOSTS and QUICKSIGHT_DOMAINS * Read DEBUG from env var * Bump chart version --- ap/settings/common.py | 7 +++++-- ap/settings/local.py | 9 +++++++++ chart/Chart.yaml | 4 ++-- chart/values.yaml | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 ap/settings/local.py diff --git a/ap/settings/common.py b/ap/settings/common.py index bc606725..c6b28072 100644 --- a/ap/settings/common.py +++ b/ap/settings/common.py @@ -40,7 +40,7 @@ # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = os.environ.get("DEBUG", True) # Application definition @@ -213,7 +213,10 @@ # set this before adding the IP address below # TODO We may be able to set this in terraform instead, we should check this -QUICKSIGHT_DOMAINS = [f"https://{host}" for host in ALLOWED_HOSTS] or ["http://localhost:8000"] +QUICKSIGHT_DOMAINS = [] +for host in ALLOWED_HOSTS: + prefix = "*" if host.startswith(".") else "" + QUICKSIGHT_DOMAINS.append(f"https://{prefix}{host}") try: ALLOWED_HOSTS.append(gethostbyname(gethostname())) diff --git a/ap/settings/local.py b/ap/settings/local.py new file mode 100644 index 00000000..c7b14173 --- /dev/null +++ b/ap/settings/local.py @@ -0,0 +1,9 @@ +from .common import * # noqa + +DEBUG = True + +ALLOWED_HOSTS = [".localhost", "127.0.0.1"] + +QUICKSIGHT_DOMAINS = ["http://localhost:8000"] + +ENV = "local" diff --git a/chart/Chart.yaml b/chart/Chart.yaml index b9d5965d..919d0a10 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v2 name: analytical-platform-ui description: Analytical Platform UI type: application -version: 0.1.4 -appVersion: 0.1.4 +version: 0.1.5 +appVersion: 0.1.5 icon: https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Ministry_of_Justice_logo_%28United_Kingdom%29.svg/611px-Ministry_of_Justice_logo_%28United_Kingdom%29.svg.png maintainers: - name: moj-data-platform-robot diff --git a/chart/values.yaml b/chart/values.yaml index b707e772..b1f5d9a0 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -54,7 +54,7 @@ app: - name: DJANGO_SETTINGS_MODULE value: ap.settings - name: ALLOWED_HOSTS - value: "*.analytical-platform.service.justice.gov.uk" + value: ".analytical-platform.service.justice.gov.uk" - name: DB_USER valueFrom: secretKeyRef: