forked from GithubBackups/healthchecks
Display last notification in Integrations page.
This commit is contained in:
parent
c7a651c330
commit
2c04a42a57
@ -170,8 +170,14 @@ class Channel(models.Model):
|
|||||||
prio = int(prio)
|
prio = int(prio)
|
||||||
return user_key, prio, PO_PRIORITIES[prio]
|
return user_key, prio, PO_PRIORITIES[prio]
|
||||||
|
|
||||||
|
def latest_notification(self):
|
||||||
|
return Notification.objects.filter(channel=self).latest()
|
||||||
|
|
||||||
|
|
||||||
class Notification(models.Model):
|
class Notification(models.Model):
|
||||||
|
class Meta:
|
||||||
|
get_latest_by = "created"
|
||||||
|
|
||||||
owner = models.ForeignKey(Check)
|
owner = models.ForeignKey(Check)
|
||||||
check_status = models.CharField(max_length=6)
|
check_status = models.CharField(max_length=6)
|
||||||
channel = models.ForeignKey(Channel)
|
channel = models.ForeignKey(Channel)
|
||||||
|
@ -5,6 +5,7 @@ from itertools import tee
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.db.models import Count
|
||||||
from django.http import HttpResponseBadRequest, HttpResponseForbidden
|
from django.http import HttpResponseBadRequest, HttpResponseForbidden
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@ -266,6 +267,8 @@ def channels(request):
|
|||||||
return redirect("hc-channels")
|
return redirect("hc-channels")
|
||||||
|
|
||||||
channels = Channel.objects.filter(user=request.user).order_by("created")
|
channels = Channel.objects.filter(user=request.user).order_by("created")
|
||||||
|
channels = channels.annotate(n_checks=Count("checks"))
|
||||||
|
|
||||||
num_checks = Check.objects.filter(user=request.user).count()
|
num_checks = Check.objects.filter(user=request.user).count()
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
|
@ -46,5 +46,6 @@ $(function() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
});
|
});
|
@ -13,6 +13,7 @@
|
|||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th>Value</th>
|
<th>Value</th>
|
||||||
<th>Assigned Checks</th>
|
<th>Assigned Checks</th>
|
||||||
|
<th>Last Notification</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for ch in channels %}
|
{% for ch in channels %}
|
||||||
@ -47,9 +48,24 @@
|
|||||||
<a
|
<a
|
||||||
class="edit-checks"
|
class="edit-checks"
|
||||||
href="{% url 'hc-channel-checks' ch.code %}">
|
href="{% url 'hc-channel-checks' ch.code %}">
|
||||||
{{ ch.checks.count }} of {{ num_checks }}
|
{{ ch.n_checks }} of {{ num_checks }}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{% with n=ch.latest_notification %}
|
||||||
|
{% if n %}
|
||||||
|
{% if n.error %}
|
||||||
|
<span class="text-danger" data-toggle="tooltip" title="{{ n.error }}">
|
||||||
|
<strong>Failed</strong>, {{ n.created|naturaltime }}
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
Delivered, {{ n.created|naturaltime }}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
Never
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button
|
<button
|
||||||
data-name="{{ ch.value }}"
|
data-name="{{ ch.value }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user