Browse Source

Use Ping.kind instead of Ping.start and Ping.fail when displaying logs and ping details.

pull/211/head
Pēteris Caune 6 years ago
parent
commit
99d46a0ca8
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
5 changed files with 9 additions and 9 deletions
  1. +2
    -2
      hc/front/tests/test_ping_details.py
  2. +1
    -1
      hc/front/views.py
  3. +2
    -2
      templates/front/details_events.html
  4. +2
    -2
      templates/front/log.html
  5. +2
    -2
      templates/front/ping_details.html

+ 2
- 2
hc/front/tests/test_ping_details.py View File

@ -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="[email protected]", 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="[email protected]", password="password")
r = self.client.get("/checks/%s/last_ping/" % check.code)


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

@ -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)


+ 2
- 2
templates/front/details_events.html View File

@ -10,9 +10,9 @@
<td class="date"></td>
<td class="time"></td>
<td class="text-right">
{% if event.fail %}
{% if event.kind == "fail" %}
<span class="label label-danger">Failure</span>
{% elif event.start %}
{% elif event.kind == "start" %}
<span class="label label-start">Started</span>
{% else %}
<span class="label label-success">OK</span>


+ 2
- 2
templates/front/log.html View File

@ -44,9 +44,9 @@
<td class="date"></td>
<td class="time"></td>
<td class="text-right">
{% if event.fail %}
{% if event.kind == "fail" %}
<span class="label label-danger">Failure</span>
{% elif event.start %}
{% elif event.kind == "start" %}
<span class="label label-start">Started</span>
{% else %}
<span class="label label-success">OK</span>


+ 2
- 2
templates/front/ping_details.html View File

@ -1,8 +1,8 @@
<div class="modal-body">
<h3>Ping #{{ ping.n }}
{% if ping.fail %}
{% if ping.kind == "fail" %}
<span class="text-danger">(received via the <code>/fail</code> endpoint)</span>
{% elif ping.start %}
{% elif ping.kind == "start" %}
<span class="text-success">(received via the <code>/start</code> endpoint)</span>
{% endif %}
</h3>


Loading…
Cancel
Save