From 99d46a0ca887525ea6d7504ebe2f4083fdb3d848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 4 Jan 2019 12:07:27 +0200 Subject: [PATCH] Use Ping.kind instead of Ping.start and Ping.fail when displaying logs and ping details. --- hc/front/tests/test_ping_details.py | 4 ++-- hc/front/views.py | 2 +- templates/front/details_events.html | 4 ++-- templates/front/log.html | 4 ++-- templates/front/ping_details.html | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hc/front/tests/test_ping_details.py b/hc/front/tests/test_ping_details.py index 1b26e8b1..b1c96f19 100644 --- a/hc/front/tests/test_ping_details.py +++ b/hc/front/tests/test_ping_details.py @@ -18,7 +18,7 @@ class LastPingTestCase(BaseTestCase): check = Check(user=self.alice) check.save() - Ping.objects.create(owner=check, fail=True) + Ping.objects.create(owner=check, kind="fail") self.client.login(username="alice@example.org", password="password") r = self.client.get("/checks/%s/last_ping/" % check.code) @@ -28,7 +28,7 @@ class LastPingTestCase(BaseTestCase): check = Check(user=self.alice) check.save() - Ping.objects.create(owner=check, start=True) + Ping.objects.create(owner=check, kind="start") self.client.login(username="alice@example.org", password="password") r = self.client.get("/checks/%s/last_ping/" % check.code) diff --git a/hc/front/views.py b/hc/front/views.py index 5a220cfd..668189b7 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -377,7 +377,7 @@ def _get_events(check, limit): prev = None for ping in pings: - if ping.start and prev and not prev.start: + if ping.kind == "start" and prev and prev.kind != "start": delta = prev.created - ping.created if delta < ONE_HOUR: setattr(prev, "delta", delta) diff --git a/templates/front/details_events.html b/templates/front/details_events.html index 14133174..08593bf4 100644 --- a/templates/front/details_events.html +++ b/templates/front/details_events.html @@ -10,9 +10,9 @@ - {% if event.fail %} + {% if event.kind == "fail" %} Failure - {% elif event.start %} + {% elif event.kind == "start" %} Started {% else %} OK diff --git a/templates/front/log.html b/templates/front/log.html index bf0a1f15..22a9db65 100644 --- a/templates/front/log.html +++ b/templates/front/log.html @@ -44,9 +44,9 @@ - {% if event.fail %} + {% if event.kind == "fail" %} Failure - {% elif event.start %} + {% elif event.kind == "start" %} Started {% else %} OK diff --git a/templates/front/ping_details.html b/templates/front/ping_details.html index d273657c..f2be8872 100644 --- a/templates/front/ping_details.html +++ b/templates/front/ping_details.html @@ -1,8 +1,8 @@