Browse Source

Cleanup, handle "paused" state in email alerts and reports

pull/81/head
Pēteris Caune 8 years ago
parent
commit
4f3365e235
4 changed files with 14 additions and 2 deletions
  1. +1
    -1
      hc/api/models.py
  2. +10
    -0
      hc/api/tests/test_check_model.py
  3. +1
    -1
      hc/front/views.py
  4. +2
    -0
      templates/emails/summary-html.html

+ 1
- 1
hc/api/models.py View File

@ -92,7 +92,7 @@ class Check(models.Model):
return "down" return "down"
def in_grace_period(self): def in_grace_period(self):
if not self.last_ping:
if self.status in ("new", "paused"):
return False return False
up_ends = self.last_ping + self.timeout up_ends = self.last_ping + self.timeout


+ 10
- 0
hc/api/tests/test_check_model.py View File

@ -27,3 +27,13 @@ class CheckModelTestCase(TestCase):
self.assertTrue(check.in_grace_period()) self.assertTrue(check.in_grace_period())
self.assertEqual(check.get_status(), "up") self.assertEqual(check.get_status(), "up")
def test_paused_check_is_not_in_grace_period(self):
check = Check()
check.status = "up"
check.last_ping = timezone.now() - timedelta(days=1, minutes=30)
self.assertTrue(check.in_grace_period())
check.status = "paused"
self.assertFalse(check.in_grace_period())

+ 1
- 1
hc/front/views.py View File

@ -44,7 +44,7 @@ def my_checks(request):
if status == "down": if status == "down":
down_tags.add(tag) down_tags.add(tag)
elif check.in_grace_period() and status != "paused":
elif check.in_grace_period():
grace_tags.add(tag) grace_tags.add(tag)
ctx = { ctx = {


+ 2
- 0
templates/emails/summary-html.html View File

@ -57,6 +57,8 @@
<td> <td>
{% if check.get_status == "new" %} {% if check.get_status == "new" %}
<span class="badge new">NEW</span> <span class="badge new">NEW</span>
{% elif check.get_status == "paused" %}
<span class="badge new">PAUSED</span>
{% elif check.in_grace_period %} {% elif check.in_grace_period %}
<span class="badge grace">LATE</span> <span class="badge grace">LATE</span>
{% elif check.get_status == "up" %} {% elif check.get_status == "up" %}


Loading…
Cancel
Save