Skip to content

Commit 31bc616

Browse files
authored
Merge pull request #1246 from NHSDigital/DTOSS-12497-environment-banner
Environment banner
2 parents af742ad + db2dea0 commit 31bc616

5 files changed

Lines changed: 35 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
@@ -51,6 +51,24 @@ a[href="#"] {
5151
color: #c80000 !important;
5252
}
5353

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

manage_breast_screening/config/jinja2_env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def environment(**options):
4141
"raise": raise_helper,
4242
"static": static,
4343
"url": reverse,
44+
"DJANGO_ENV": settings.DJANGO_ENV,
4445
}
4546
)
4647

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

@@ -76,7 +78,7 @@ def list_env(key):
7678
"ninja",
7779
]
7880

79-
if DJANGO_ENV != "production":
81+
if not IS_PRODUCTION:
8082
INSTALLED_APPS.append("manage_breast_screening.nonprod")
8183

8284
MIDDLEWARE = [
@@ -178,7 +180,7 @@ def list_env(key):
178180
}
179181

180182

181-
if DJANGO_ENV != "production":
183+
if not IS_PRODUCTION:
182184
if environ.get("BLOB_STORAGE_CONNECTION_STRING"):
183185
# Use connection string if provided (e.g., in local development using Azurite)
184186
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
from datetime import datetime, timedelta
3-
from os import getenv
43

54
import yaml
65
from django.conf import settings
@@ -79,7 +78,7 @@ def diagram_file(self, file_name):
7978
return open(MAMMOGRAM_DIAGRAMS_DIR / file_name, "rb")
8079

8180
def handle(self, *args, **kwargs):
82-
if getenv("DJANGO_ENV", "production") == "production":
81+
if settings.IS_PRODUCTION:
8382
raise Exception("This command cannot be run in production")
8483

8584
if not kwargs["noinput"]:

0 commit comments

Comments
 (0)