Skip to content

Commit ba353c9

Browse files
committed
Environment banner
Uses DJANGO_ENV to determine environment name
1 parent 7693ff8 commit ba353c9

5 files changed

Lines changed: 37 additions & 4 deletions

File tree

manage_breast_screening/assets/sass/main.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ a[href="#"] {
5050
color: #c80000 !important;
5151
}
5252

53+
// Environment banner at the top of the page
54+
.app-environment {
55+
@include nhsuk-font-size(14);
56+
@include nhsuk-responsive-padding(2, bottom);
57+
@include nhsuk-responsive-padding(2, top);
58+
59+
.nhsuk-link {
60+
color: inherit;
61+
}
62+
63+
.nhsuk-width-container {
64+
align-items: baseline;
65+
display: flex;
66+
flex-wrap: wrap;
67+
gap: nhsuk-spacing(1) nhsuk-spacing(2);
68+
}
69+
}
70+
5371
// Status tag positioning within headers
5472
.app-header {
5573
position: relative;

manage_breast_screening/config/jinja2_env.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def environment(**options):
4141
"static": static,
4242
"url": reverse,
4343
"inflector": inflector,
44+
"DJANGO_ENV": settings.DJANGO_ENV,
45+
"IS_PRODUCTION": settings.IS_PRODUCTION,
4446
}
4547
)
4648

manage_breast_screening/config/settings/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def list_env(key):
3434

3535
DJANGO_ENV = environ.get("DJANGO_ENV", "production")
3636

37+
IS_PRODUCTION = DJANGO_ENV == "production"
38+
3739
ALLOWED_HOSTS = list_env("ALLOWED_HOSTS")
3840
CSRF_TRUSTED_ORIGINS = list_env("CSRF_TRUSTED_ORIGINS")
3941

@@ -74,7 +76,7 @@ def list_env(key):
7476
"csp",
7577
]
7678

77-
if DJANGO_ENV != "production":
79+
if not IS_PRODUCTION:
7880
INSTALLED_APPS.append("manage_breast_screening.nonprod")
7981

8082
MIDDLEWARE = [
@@ -176,7 +178,7 @@ def list_env(key):
176178
}
177179

178180

179-
if DJANGO_ENV != "production":
181+
if not IS_PRODUCTION:
180182
if environ.get("BLOB_STORAGE_CONNECTION_STRING"):
181183
# Use connection string if provided (e.g., in local development using Azurite)
182184
dicom_storage_options = {

manage_breast_screening/core/jinja2/layout-app.jinja

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
{% block pageTitle %}{% if form and form.errors %}Error: {% endif %}{% if page_title %}{{ page_title }} – {% endif %}Manage breast screening – NHS{% endblock %}
1515

1616
{% block header %}
17+
{% if not IS_PRODUCTION %}
18+
<div class="app-environment nhsuk-tag--grey">
19+
<div class="nhsuk-width-container">
20+
<strong class="nhsuk-tag nhsuk-tag--grey">
21+
{{ DJANGO_ENV }}
22+
</strong>
23+
This is the {{ DJANGO_ENV }} environment.
24+
</div>
25+
</div>
26+
{% endif %}
27+
1728
{{ header({
1829
"classes": "nhsuk-header--inline",
1930
"service": {

manage_breast_screening/nonprod/management/commands/seed_demo_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22
from datetime import datetime, timedelta
3-
from os import getenv
43

54
import yaml
5+
from django.conf import settings
66
from django.core.management.base import BaseCommand
77
from django.db import connection
88
from django.test import override_settings
@@ -52,7 +52,7 @@ def file_from_name(self, file_name):
5252
return open("manage_breast_screening/data/" + file_name)
5353

5454
def handle(self, *args, **kwargs):
55-
if getenv("DJANGO_ENV", "production") == "production":
55+
if settings.IS_PRODUCTION:
5656
raise Exception("This command cannot be run in production")
5757

5858
if not kwargs["noinput"]:

0 commit comments

Comments
 (0)