From ad6d080ad94ef7726d88d38adaa58b02cbbecc5e Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Fri, 2 Feb 2024 15:11:22 -0500 Subject: [PATCH 1/5] Add non-prod banner --- src/registrar/assets/sass/_theme/_alerts.scss | 5 +- src/registrar/templates/admin/base_site.html | 79 ++++++++++++------- src/registrar/templates/base.html | 4 + .../includes/non-production-alert.html | 5 ++ .../test_environment_variables_effects.py | 29 +++++++ 5 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 src/registrar/templates/includes/non-production-alert.html create mode 100644 src/registrar/tests/test_environment_variables_effects.py diff --git a/src/registrar/assets/sass/_theme/_alerts.scss b/src/registrar/assets/sass/_theme/_alerts.scss index 9ee28a357..163f243d3 100644 --- a/src/registrar/assets/sass/_theme/_alerts.scss +++ b/src/registrar/assets/sass/_theme/_alerts.scss @@ -17,5 +17,8 @@ .usa-alert__body::before { left: 1rem !important; } - } + } + .usa-alert__body.margin-left-1 { + margin-left: 0.5rem!important; + } } diff --git a/src/registrar/templates/admin/base_site.html b/src/registrar/templates/admin/base_site.html index c0884c912..f9ff23455 100644 --- a/src/registrar/templates/admin/base_site.html +++ b/src/registrar/templates/admin/base_site.html @@ -24,34 +24,57 @@ {% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %} {% block extrastyle %}{{ block.super }} - + {% endblock %} -{% block branding %} -

.gov admin

-{% if user.is_anonymous %} - {% include "admin/color_theme_toggle.html" %} -{% endif %} +{% block header %} + {% if not IS_PRODUCTION %} + {% with add_body_class="margin-left-1" %} + {% include "includes/non-production-alert.html" %} + {% endwith %} + {% endif %} + + {# Djando update: this div will change to header #} + {% endblock %} -{% comment %} - This was copied from the 'userlinks' template, with a few minor changes. - You can find that here: - https://github.com/django/django/blob/d25f3892114466d689fd6936f79f3bd9a9acc30e/django/contrib/admin/templates/admin/base.html#L59 -{% endcomment %} -{% block userlinks %} - {% if site_url %} - {% translate 'View site' %} / - {% endif %} - {% if user.is_active and user.is_staff %} - {% url 'django-admindocs-docroot' as docsroot %} - {% if docsroot %} - {% translate 'Documentation' %} / - {% endif %} - {% endif %} - {% if user.has_usable_password %} - {% translate 'Change password' %} / - {% endif %} - {% translate 'Log out' %} - {% include "admin/color_theme_toggle.html" %} - {% endblock %} -{% block nav-global %}{% endblock %} \ No newline at end of file diff --git a/src/registrar/templates/base.html b/src/registrar/templates/base.html index 2786cca22..c0702e78f 100644 --- a/src/registrar/templates/base.html +++ b/src/registrar/templates/base.html @@ -70,6 +70,10 @@ Skip to main content + {% if not IS_PRODUCTION %} + {% include "includes/non-production-alert.html" %} + {% endif %} +
diff --git a/src/registrar/templates/includes/non-production-alert.html b/src/registrar/templates/includes/non-production-alert.html new file mode 100644 index 000000000..e4ce21437 --- /dev/null +++ b/src/registrar/templates/includes/non-production-alert.html @@ -0,0 +1,5 @@ +
+
+ You are not on production. +
+
diff --git a/src/registrar/tests/test_environment_variables_effects.py b/src/registrar/tests/test_environment_variables_effects.py new file mode 100644 index 000000000..03706f179 --- /dev/null +++ b/src/registrar/tests/test_environment_variables_effects.py @@ -0,0 +1,29 @@ +from django.test import Client, TestCase, override_settings +from django.contrib.auth import get_user_model + + +class MyTestCase(TestCase): + def setUp(self): + self.client = Client() + username = "test_user" + first_name = "First" + last_name = "Last" + email = "info@example.com" + self.user = get_user_model().objects.create( + username=username, first_name=first_name, last_name=last_name, email=email + ) + self.client.force_login(self.user) + + def tearDown(self): + super().tearDown() + self.user.delete() + + @override_settings(IS_PRODUCTION=True) + def test_production_environment(self): + home_page = self.client.get("/") + self.assertNotContains(home_page, "You are not on production.") + + @override_settings(IS_PRODUCTION=False) + def test_non_production_environment(self): + home_page = self.client.get("/") + self.assertContains(home_page, "You are not on production.") From fa8122b2179e85a0b1038ce2e98cb2b60678bd4e Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Fri, 2 Feb 2024 15:16:38 -0500 Subject: [PATCH 2/5] Add test defs --- src/registrar/tests/test_environment_variables_effects.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/registrar/tests/test_environment_variables_effects.py b/src/registrar/tests/test_environment_variables_effects.py index 03706f179..9ef065aeb 100644 --- a/src/registrar/tests/test_environment_variables_effects.py +++ b/src/registrar/tests/test_environment_variables_effects.py @@ -20,10 +20,12 @@ class MyTestCase(TestCase): @override_settings(IS_PRODUCTION=True) def test_production_environment(self): + """No banner on prod.""" home_page = self.client.get("/") self.assertNotContains(home_page, "You are not on production.") @override_settings(IS_PRODUCTION=False) def test_non_production_environment(self): + """Banner on non-prod.""" home_page = self.client.get("/") self.assertContains(home_page, "You are not on production.") From 02d147ae114349fc1ea5295bb31a450f51ce467e Mon Sep 17 00:00:00 2001 From: rachidatecs <107004823+rachidatecs@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:56:46 -0500 Subject: [PATCH 3/5] Update src/registrar/templates/includes/non-production-alert.html Co-authored-by: zandercymatics <141044360+zandercymatics@users.noreply.github.com> --- src/registrar/templates/includes/non-production-alert.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/templates/includes/non-production-alert.html b/src/registrar/templates/includes/non-production-alert.html index e4ce21437..4f8aaeac0 100644 --- a/src/registrar/templates/includes/non-production-alert.html +++ b/src/registrar/templates/includes/non-production-alert.html @@ -1,5 +1,5 @@
- You are not on production. + WARNING: You are not on production.
From 0eac1db3ad6f2e9b6d463c496383d94893d07c04 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Wed, 7 Feb 2024 11:00:21 -0500 Subject: [PATCH 4/5] Revise banner color and copy --- src/registrar/assets/sass/_theme/_uswds-theme.scss | 4 ++++ src/registrar/templates/includes/non-production-alert.html | 4 ++-- src/registrar/tests/test_environment_variables_effects.py | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_uswds-theme.scss b/src/registrar/assets/sass/_theme/_uswds-theme.scss index 0cdf6675e..a26f23508 100644 --- a/src/registrar/assets/sass/_theme/_uswds-theme.scss +++ b/src/registrar/assets/sass/_theme/_uswds-theme.scss @@ -116,6 +116,10 @@ in the form $setting: value, $theme-color-success-light: $dhs-green-30, $theme-color-success-lighter: $dhs-green-15, + /*--------------------------- + ## Emergency state + ----------------------------*/ + $theme-color-emergency: #FFC3F9, /*--------------------------- # Input settings diff --git a/src/registrar/templates/includes/non-production-alert.html b/src/registrar/templates/includes/non-production-alert.html index 4f8aaeac0..811e1f9de 100644 --- a/src/registrar/templates/includes/non-production-alert.html +++ b/src/registrar/templates/includes/non-production-alert.html @@ -1,5 +1,5 @@ -
+
- WARNING: You are not on production. + WARNING: You are on a test site.
diff --git a/src/registrar/tests/test_environment_variables_effects.py b/src/registrar/tests/test_environment_variables_effects.py index 9ef065aeb..3a838c2a2 100644 --- a/src/registrar/tests/test_environment_variables_effects.py +++ b/src/registrar/tests/test_environment_variables_effects.py @@ -22,10 +22,10 @@ class MyTestCase(TestCase): def test_production_environment(self): """No banner on prod.""" home_page = self.client.get("/") - self.assertNotContains(home_page, "You are not on production.") + self.assertNotContains(home_page, "You are on a test site.") @override_settings(IS_PRODUCTION=False) def test_non_production_environment(self): """Banner on non-prod.""" home_page = self.client.get("/") - self.assertContains(home_page, "You are not on production.") + self.assertContains(home_page, "You are on a test site.") From 8f1ab863ee8e22678a38ef1cf2206fd025d1c17c Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Wed, 7 Feb 2024 11:44:09 -0500 Subject: [PATCH 5/5] Change warning to attention --- src/registrar/templates/includes/non-production-alert.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/templates/includes/non-production-alert.html b/src/registrar/templates/includes/non-production-alert.html index 811e1f9de..8e40892bc 100644 --- a/src/registrar/templates/includes/non-production-alert.html +++ b/src/registrar/templates/includes/non-production-alert.html @@ -1,5 +1,5 @@
- WARNING: You are on a test site. + Attention: You are on a test site.