mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
Add non-prod banner
This commit is contained in:
parent
10aa1c8e59
commit
ad6d080ad9
5 changed files with 93 additions and 29 deletions
|
@ -18,4 +18,7 @@
|
||||||
left: 1rem !important;
|
left: 1rem !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.usa-alert__body.margin-left-1 {
|
||||||
|
margin-left: 0.5rem!important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,21 +24,39 @@
|
||||||
{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
|
{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
|
||||||
|
|
||||||
{% block extrastyle %}{{ block.super }}
|
{% block extrastyle %}{{ block.super }}
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/styles.css" %}" />
|
<link rel="stylesheet" type="text/css" href="{% static 'css/styles.css' %}" />
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block branding %}
|
{% block header %}
|
||||||
<h1 id="site-name"><a href="{% url 'admin:index' %}">.gov admin</a></h1>
|
{% if not IS_PRODUCTION %}
|
||||||
{% if user.is_anonymous %}
|
{% with add_body_class="margin-left-1" %}
|
||||||
|
{% include "includes/non-production-alert.html" %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# Djando update: this div will change to header #}
|
||||||
|
<div id="header">
|
||||||
|
<div id="branding">
|
||||||
|
{% block branding %}
|
||||||
|
<h1 id="site-name"><a href="{% url 'admin:index' %}">.gov admin</a></h1>
|
||||||
|
{% if user.is_anonymous %}
|
||||||
{% include "admin/color_theme_toggle.html" %}
|
{% include "admin/color_theme_toggle.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% comment %}
|
</div>
|
||||||
|
{% block usertools %}
|
||||||
|
{% if has_permission %}
|
||||||
|
<div id="user-tools">
|
||||||
|
{% block welcome-msg %}
|
||||||
|
{% translate 'Welcome,' %}
|
||||||
|
<strong>{% firstof user.get_short_name user.get_username %}</strong>.
|
||||||
|
{% endblock %}
|
||||||
|
{% comment %}
|
||||||
This was copied from the 'userlinks' template, with a few minor changes.
|
This was copied from the 'userlinks' template, with a few minor changes.
|
||||||
You can find that here:
|
You can find that here:
|
||||||
https://github.com/django/django/blob/d25f3892114466d689fd6936f79f3bd9a9acc30e/django/contrib/admin/templates/admin/base.html#L59
|
https://github.com/django/django/blob/d25f3892114466d689fd6936f79f3bd9a9acc30e/django/contrib/admin/templates/admin/base.html#L59
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
{% block userlinks %}
|
{% block userlinks %}
|
||||||
{% if site_url %}
|
{% if site_url %}
|
||||||
<a href="{{ site_url }}">{% translate 'View site' %}</a> /
|
<a href="{{ site_url }}">{% translate 'View site' %}</a> /
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -54,4 +72,9 @@
|
||||||
<a href="{% url 'admin:logout' %}" id="admin-logout-button">{% translate 'Log out' %}</a>
|
<a href="{% url 'admin:logout' %}" id="admin-logout-button">{% translate 'Log out' %}</a>
|
||||||
{% include "admin/color_theme_toggle.html" %}
|
{% include "admin/color_theme_toggle.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block nav-global %}{% endblock %}
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block nav-global %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -70,6 +70,10 @@
|
||||||
<script src="{% static 'js/uswds.min.js' %}" defer></script>
|
<script src="{% static 'js/uswds.min.js' %}" defer></script>
|
||||||
<a class="usa-skipnav" href="#main-content">Skip to main content</a>
|
<a class="usa-skipnav" href="#main-content">Skip to main content</a>
|
||||||
|
|
||||||
|
{% if not IS_PRODUCTION %}
|
||||||
|
{% include "includes/non-production-alert.html" %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<section class="usa-banner" aria-label="Official website of the United States government">
|
<section class="usa-banner" aria-label="Official website of the United States government">
|
||||||
<div class="usa-accordion">
|
<div class="usa-accordion">
|
||||||
<header class="usa-banner__header">
|
<header class="usa-banner__header">
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<div class="usa-alert usa-alert--warning usa-alert--slim margin-y-0 {% if add_class %}{{ add_class }}{% endif %}">
|
||||||
|
<div class="usa-alert__body {% if add_body_class %}{{ add_body_class }}{% endif %}">
|
||||||
|
You are not on production.
|
||||||
|
</div>
|
||||||
|
</div>
|
29
src/registrar/tests/test_environment_variables_effects.py
Normal file
29
src/registrar/tests/test_environment_variables_effects.py
Normal file
|
@ -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.")
|
Loading…
Add table
Add a link
Reference in a new issue