Browse Source

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

pull/199/head
Pēteris Caune 6 years ago
parent
commit
0ece2664ac
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
5 changed files with 27 additions and 2 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +12
    -0
      hc/front/templatetags/hc_extras.py
  3. +6
    -2
      hc/front/tests/test_basics.py
  4. +7
    -0
      static/css/base.css
  5. +1
    -0
      templates/base.html

+ 1
- 0
CHANGELOG.md 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


+ 12
- 0
hc/front/templatetags/hc_extras.py 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)),)


+ 6
- 2
hc/front/tests/test_basics.py 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):


+ 7
- 0
static/css/base.css 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;
}

+ 1
- 0
templates/base.html 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">


Loading…
Cancel
Save