forked from GithubBackups/healthchecks
Nicer emails
This commit is contained in:
parent
c21b6b699b
commit
2abec6ff6a
@ -4,6 +4,7 @@ import uuid
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from hc.lib.emails import send
|
from hc.lib.emails import send
|
||||||
|
|
||||||
@ -40,7 +41,9 @@ class Check(models.Model):
|
|||||||
ctx = {
|
ctx = {
|
||||||
"timeout_choices": TIMEOUT_CHOICES,
|
"timeout_choices": TIMEOUT_CHOICES,
|
||||||
"check": self,
|
"check": self,
|
||||||
"checks": self.user.check_set.order_by("created")
|
"checks": self.user.check_set.order_by("created"),
|
||||||
|
"now": timezone.now()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.status in ("up", "down"):
|
if self.status in ("up", "down"):
|
||||||
|
@ -7,6 +7,7 @@ urlpatterns = [
|
|||||||
url(r'^checks/add/$', views.add_check, name="hc-add-check"),
|
url(r'^checks/add/$', views.add_check, name="hc-add-check"),
|
||||||
url(r'^checks/([\w-]+)/name/$', views.update_name, name="hc-update-name"),
|
url(r'^checks/([\w-]+)/name/$', views.update_name, name="hc-update-name"),
|
||||||
url(r'^checks/([\w-]+)/timeout/$', views.update_timeout, name="hc-update-timeout"),
|
url(r'^checks/([\w-]+)/timeout/$', views.update_timeout, name="hc-update-timeout"),
|
||||||
|
url(r'^checks/([\w-]+)/email/$', views.email_preview),
|
||||||
url(r'^pricing/$', views.pricing, name="hc-pricing"),
|
url(r'^pricing/$', views.pricing, name="hc-pricing"),
|
||||||
url(r'^docs/$', views.docs, name="hc-docs"),
|
url(r'^docs/$', views.docs, name="hc-docs"),
|
||||||
url(r'^about/$', views.about, name="hc-about"),
|
url(r'^about/$', views.about, name="hc-about"),
|
||||||
|
@ -41,7 +41,7 @@ def _my_checks(request):
|
|||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
"checks": checks,
|
"checks": checks,
|
||||||
"now": timezone.now,
|
"now": timezone.now(),
|
||||||
"timeout_choices": TIMEOUT_CHOICES
|
"timeout_choices": TIMEOUT_CHOICES
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,3 +104,27 @@ def update_timeout(request, code):
|
|||||||
check.save()
|
check.save()
|
||||||
|
|
||||||
return redirect("hc-index")
|
return redirect("hc-index")
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def email_preview(request, code):
|
||||||
|
""" A debug view to see how email will look.
|
||||||
|
|
||||||
|
Will keep it around until I'm happy with email stying.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
check = Check.objects.get(code=code)
|
||||||
|
if check.user != request.user:
|
||||||
|
return HttpResponseForbidden()
|
||||||
|
|
||||||
|
from hc.api.models import TIMEOUT_CHOICES
|
||||||
|
ctx = {
|
||||||
|
"check": check,
|
||||||
|
"checks": check.user.check_set.all(),
|
||||||
|
"timeout_choices": TIMEOUT_CHOICES,
|
||||||
|
"now": timezone.now()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return render(request, "emails/alert/body.html", ctx)
|
||||||
|
@ -1,8 +1,36 @@
|
|||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
th {
|
||||||
|
text-align: left;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
font-size: 10px;
|
||||||
|
color: white;
|
||||||
|
padding: 4px;
|
||||||
|
font-family: sans;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new { background: #AAA; }
|
||||||
|
.up { background: #5cb85c; }
|
||||||
|
.down { background: #d9534f; }
|
||||||
|
.unnamed {
|
||||||
|
color: #888;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<p>Hello,</p>
|
<p>Hello,</p>
|
||||||
<p>This is a notification sent by healthchecks.io</p>
|
<p>This is a notification sent by <a href="https://healthchecks.io">healthchecks.io</a>.</p>
|
||||||
<p>The check "{{ check.name }}" has gone {{ check.status }}.</p>
|
<p>The check "{{ check.name|default:check.code }}" has gone {{ check.status }}.</p>
|
||||||
<p>Here is a summary of all your checks:</p>
|
<p>Here is a summary of all your checks:</p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
@ -17,15 +45,19 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if check.status == "new" %}
|
{% if check.status == "new" %}
|
||||||
<span class="glyphicon glyphicon-question-sign new"></span>
|
<span class="badge new">NEW</span>
|
||||||
{% elif now < check.alert_after %}
|
{% elif now < check.alert_after %}
|
||||||
<span class="glyphicon glyphicon-ok-sign up"></span>
|
<span class="badge up">UP</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="glyphicon glyphicon-exclamation-sign down"></span>
|
<span class="badge down">DOWN</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ check.name }}
|
{% if check.name %}
|
||||||
|
{{ check.name }}
|
||||||
|
{% else %}
|
||||||
|
<span class="unnamed">unnamed</span>
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="url-cell">
|
<td class="url-cell">
|
||||||
<code>{{ check.url }}</code>
|
<code>{{ check.url }}</code>
|
||||||
@ -48,4 +80,8 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
--<br />
|
||||||
|
Regards,<br />
|
||||||
|
healthchecks.io
|
||||||
|
</p>
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<p>Hello from healthchecks.io!</p>
|
<p>Hello,</p>
|
||||||
|
|
||||||
<p>Here's a link to log yourself in:</p>
|
<p>Here's a link to log yourself in:</p>
|
||||||
<p><a href="{{ login_link }}">{{ login_link }}</a></p>
|
<p><a href="{{ login_link }}">{{ login_link }}</a></p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
--<br />
|
||||||
|
Regards,<br />
|
||||||
|
healthchecks.io
|
||||||
|
</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user