Show a warning when running with DEBUG=True. Fixes #189

This commit is contained in:
Pēteris Caune 2018-11-06 10:48:59 +02:00
parent 5ef67e8bbf
commit 0ece2664ac
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
5 changed files with 27 additions and 2 deletions

View File

@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
- Add search box in the "My Checks" page
- Add read-only API key support
- Remove Profile.bill_to field (obsolete)
- Show a warning when running with DEBUG=True
### Bug Fixes
- During DST transition, handle ambiguous dates as pre-transition

View File

@ -35,6 +35,18 @@ def site_root():
return settings.SITE_ROOT
@register.simple_tag
def debug_warning():
if settings.DEBUG:
return mark_safe("""
<div id="debug-warning">
Running in debug mode, do not use in production.
</div>
""")
return ""
def naturalize_int_match(match):
return '%08d' % (int(match.group(0)),)

View File

@ -1,14 +1,18 @@
from django.test import TestCase
from django.test.utils import override_settings
from hc.api.models import Check
class BasicsTestCase(TestCase):
def test_it_shows_welcome(self):
r = self.client.get("/")
self.assertContains(r, "Get Notified", status_code=200)
self.assertNotContains(r, "do not use in production")
@override_settings(DEBUG=True)
def test_it_shows_debug_warning(self):
r = self.client.get("/")
self.assertContains(r, "do not use in production")
@override_settings(REGISTRATION_OPEN=False)
def test_it_obeys_registration_open(self):

View File

@ -93,3 +93,10 @@ pre {
.jumbotron p {
font-weight: 300;
}
#debug-warning {
background: #eeeeee;
text-align: center;
font-size: small;
padding: 2px 0;
}

View File

@ -46,6 +46,7 @@
{% endcompress %}
</head>
<body class="page-{{ page }}">
{% debug_warning %}
<nav class="navbar navbar-default">
<div class="container{% if page == "checks" or page == "details" %}-fluid{% endif %}">
<div class="navbar-header">