Merge lp:~cjohnston/qa-dashboard/staging-env-notice into lp:qa-dashboard

Proposed by Chris Johnston
Status: Merged
Approved by: Joe Talbott
Approved revision: 149
Merged at revision: 149
Proposed branch: lp:~cjohnston/qa-dashboard/staging-env-notice
Merge into: lp:qa-dashboard
Prerequisite: lp:~cjohnston/qa-dashboard/url-fixes
Diff against target: 184 lines (+105/-17)
8 files modified
common/static/css/style.css (+29/-0)
common/templates/banner.html (+4/-0)
common/templates/layout.html (+5/-1)
common/templatetags/instance.py (+15/-0)
common/tests.py (+0/-16)
common/tests/__init__.py (+1/-0)
common/tests/test_instance.py (+50/-0)
qa_dashboard/settings.py (+1/-0)
To merge this branch: bzr merge lp:~cjohnston/qa-dashboard/staging-env-notice
Reviewer Review Type Date Requested Status
Joe Talbott Approve
Review via email: mp+135257@code.launchpad.net

Commit message

Adds a staging notice to all pages in a non-production environment

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :

Would it be better to change the conditional to if not equal to 'production' then show the staging banner?

review: Needs Information
149. By Chris Johnston

Changes settings.CONFIGURATION to staging and local_settings.CONFIGURATION to production

Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks great. Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/static/css/style.css'
2--- common/static/css/style.css 2012-06-27 14:08:10 +0000
3+++ common/static/css/style.css 2012-11-21 02:26:19 +0000
4@@ -146,3 +146,32 @@
5 color: #999;
6 font-size: 60%;
7 }
8+
9+.banner {
10+ position: fixed;
11+ z-index: 10;
12+ bottom: 0;
13+ left: 0;
14+ right: 0;
15+ background-color: rgba(139, 0, 0, 0.8);
16+ color: white;
17+ text-shadow: 0 -1px 0 #631616;
18+ -moz-box-shadow: 0 0 5px #333;
19+ -webkit-box-shadow: 0 0 5px #333;
20+ box-shdow: 0 0 5px #333;
21+ padding: 8px;
22+ height: 95px;
23+}
24+
25+.banner p {
26+ text-align: center;
27+ font-size: 1.25em;
28+}
29+
30+.banner a {
31+ color: silver;
32+}
33+
34+.banner-under {
35+ background-color: white;
36+ height: 95px;
37
38=== added file 'common/templates/banner.html'
39--- common/templates/banner.html 1970-01-01 00:00:00 +0000
40+++ common/templates/banner.html 2012-11-21 02:26:19 +0000
41@@ -0,0 +1,4 @@
42+<div id="instance" class="banner">
43+ <p>You are accessing the <strong>{{ configuration|lower }}</strong> instance of the <strong>QA Dashboard</strong>. This should only be used for testing or training.</p>
44+ <p>Please use the <strong>production</strong> instance instead: <a href="http://reports.qa.ubuntu.com" title="QA Dashboard">http://reports.qa.ubuntu.com</a>.</p>
45+</div>
46
47=== modified file 'common/templates/layout.html'
48--- common/templates/layout.html 2012-11-20 02:23:46 +0000
49+++ common/templates/layout.html 2012-11-21 02:26:19 +0000
50@@ -1,6 +1,6 @@
51 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
52
53-{% load static %}
54+{% load static instance %}
55 <html>
56 <head>
57 <link href='{% get_static_prefix %}css/grid.css' rel='stylesheet' type='text/css' />
58@@ -69,5 +69,9 @@
59 <div class='container_15 clearfix' id='content'>
60 {% block content %}{% endblock %}
61 </div>
62+ {% ifnotequal configuration|lower "production" %}
63+ <div class="banner-under"></div>
64+ {% instance_banner %}
65+ {% endifnotequal %}
66 </body>
67 </html>
68
69=== added directory 'common/templatetags'
70=== added file 'common/templatetags/__init__.py'
71=== added file 'common/templatetags/instance.py'
72--- common/templatetags/instance.py 1970-01-01 00:00:00 +0000
73+++ common/templatetags/instance.py 2012-11-21 02:26:19 +0000
74@@ -0,0 +1,15 @@
75+from django import template
76+from django.conf import settings
77+
78+register = template.Library()
79+
80+
81+def get_instance_info():
82+ return {
83+ 'configuration': settings.CONFIGURATION,
84+ }
85+
86+
87+@register.inclusion_tag('banner.html')
88+def instance_banner():
89+ return get_instance_info()
90
91=== added directory 'common/tests'
92=== removed file 'common/tests.py'
93--- common/tests.py 2012-11-14 23:03:41 +0000
94+++ common/tests.py 1970-01-01 00:00:00 +0000
95@@ -1,16 +0,0 @@
96-"""
97-This file demonstrates writing tests using the unittest module. These will pass
98-when you run "manage.py test".
99-
100-Replace this with more appropriate tests for your application.
101-"""
102-
103-from django.test import TestCase
104-
105-
106-class SimpleTest(TestCase):
107- def test_basic_addition(self):
108- """
109- Tests that 1 + 1 always equals 2.
110- """
111- self.assertEqual(1 + 1, 2)
112
113=== added file 'common/tests/__init__.py'
114--- common/tests/__init__.py 1970-01-01 00:00:00 +0000
115+++ common/tests/__init__.py 2012-11-21 02:26:19 +0000
116@@ -0,0 +1,1 @@
117+from test_instance import *
118
119=== added file 'common/tests/test_instance.py'
120--- common/tests/test_instance.py 1970-01-01 00:00:00 +0000
121+++ common/tests/test_instance.py 2012-11-21 02:26:19 +0000
122@@ -0,0 +1,50 @@
123+from django.conf import settings
124+from django.template import Template, Context
125+from django.test import TestCase
126+
127+from common.templatetags.instance import instance_banner
128+
129+
130+class TestInstanceTags(TestCase):
131+
132+ def setUp(self):
133+ super(TestInstanceTags, self).setUp()
134+ self._old_configuration = settings.CONFIGURATION
135+
136+ def tearDown(self):
137+ settings.CONFIGURATION = self._old_configuration
138+ super(TestInstanceTags, self).tearDown()
139+
140+ def assertIn(self, item1, item2, message=None):
141+ """Assert that 'item1' is contained in 'item2'."""
142+ if item1 not in item2:
143+ raise self.failureException(message or "%r not in %r" % (
144+ item1, item2))
145+
146+ def test_instance_banner_tag_exports_details(self):
147+ """
148+ The 'instance_banner' tag should make settings.CONFIGURATION
149+ available to the template.
150+ """
151+ self.assertEqual({'configuration': 'staging'},
152+ instance_banner())
153+
154+ def test_instance_banner_tag_rendered_in_development(self):
155+ """
156+ The instance tag displays a banner if the configuration is
157+ staging.
158+ """
159+ rendered = Template("{% load instance %}"
160+ "{% instance_banner %}").render(Context())
161+ self.assertIn("<p>You are accessing the <strong>staging"
162+ "</strong> instance of the <strong>QA Dashboard</strong>",
163+ rendered)
164+
165+ def test_instance_banner_hidden_in_production(self):
166+ """
167+ The instance tag renders nothing if the configuration is 'production'.
168+ """
169+ settings.CONFIGURATION = "production"
170+ rendered = Template("{% load instance %}"
171+ "{% instance_banner %}").render(Context())
172+ self.assertEqual(u"\n", rendered)
173
174=== modified file 'qa_dashboard/settings.py'
175--- qa_dashboard/settings.py 2012-11-15 02:13:32 +0000
176+++ qa_dashboard/settings.py 2012-11-21 02:26:19 +0000
177@@ -3,6 +3,7 @@
178
179 DEBUG = False
180 TEMPLATE_DEBUG = DEBUG
181+CONFIGURATION = 'staging'
182
183 ADMINS = (
184 # ('Your Name', 'your_email@example.com'),

Subscribers

People subscribed via source and target branches