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.")