0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-04-17 18:22:33 +00:00

Split report and reminder (nag) templates

This commit is contained in:
Pēteris Caune 2023-08-23 11:19:58 +03:00
parent fbc6ac58ba
commit d57ea3309a
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
11 changed files with 60 additions and 43 deletions

View file

@ -239,10 +239,10 @@ class Profile(models.Model):
for check in checks: for check in checks:
check.past_downtimes = check.downtimes_by_boundary(boundaries)[:-1] check.past_downtimes = check.downtimes_by_boundary(boundaries)[:-1]
ctx["nag"] = False
ctx["checks"] = checks ctx["checks"] = checks
ctx["boundaries"] = boundaries[:-1] ctx["boundaries"] = boundaries[:-1]
ctx["monthly_or_weekly"] = self.reports ctx["monthly_or_weekly"] = self.reports
emails.report(self.user.email, ctx, headers)
if nag: if nag:
# For nags, only show checks that are currently down # For nags, only show checks that are currently down
@ -251,10 +251,9 @@ class Profile(models.Model):
return False return False
ctx["checks"] = checks ctx["checks"] = checks
ctx["num_down"] = len(checks) ctx["num_down"] = len(checks)
ctx["nag"] = True
ctx["nag_period"] = self.nag_period.total_seconds() ctx["nag_period"] = self.nag_period.total_seconds()
emails.nag(self.user.email, ctx, headers)
emails.report(self.user.email, ctx, headers)
return True return True
def sms_sent_this_month(self): def sms_sent_this_month(self):

View file

@ -21,7 +21,6 @@ MOCK_NOW = Mock(return_value=CURRENT_TIME)
NAG_TEXT = """Hello, NAG_TEXT = """Hello,
This is a hourly reminder sent by Mychecks. This is a hourly reminder sent by Mychecks.
One check is currently DOWN: One check is currently DOWN:

View file

@ -103,6 +103,11 @@ def report(to, ctx, headers={}):
send(m, block=True) send(m, block=True)
def nag(to, ctx, headers={}):
m = make_message("nag", to, ctx, headers=headers)
send(m, block=True)
def deletion_notice(to, ctx, headers={}): def deletion_notice(to, ctx, headers={}):
m = make_message("deletion-notice", to, ctx, headers=headers) m = make_message("deletion-notice", to, ctx, headers=headers)
send(m, block=True) send(m, block=True)

View file

@ -0,0 +1,34 @@
{% extends "emails/base.html" %}
{% load humanize hc_extras %}
{% block content %}
Hello,<br />
This is a
{% if nag_period == 3600 %}hourly{% endif %}
{% if nag_period == 86400 %}daily{% endif %}
reminder sent by <a href="{% site_root %}">{% site_name %}</a>.<br />
{% if num_down == 1%}
One check is currently <strong>DOWN</strong>:<br />
{% else %}
{{ num_down }} checks are currently <strong>DOWN</strong>:<br />
{% endif %}
{% include "emails/nag-summary-html.html" %}
<strong>Too many notifications?</strong>
Visit the <a href="{{ notifications_url }}">Email Reports</a>
page on {% site_name %} to set your notification preferences.
<br /><br />
Cheers,<br>
The {% site_name %} Team
{% endblock %}
{% block unsub %}
<br>
<a href="{{ unsub_link }}" target="_blank" style="color: #666666; text-decoration: underline;">
Unsubscribe
</a>
{% endblock %}

View file

@ -0,0 +1,10 @@
{% load hc_extras %}Hello,
This is a {% if nag_period == 3600 %}hourly {% endif %}{% if nag_period == 86400 %}daily {% endif %}reminder sent by {% site_name %}.
{% if num_down == 1%}One check is currently DOWN:{% else %}{{ num_down }} checks are currently DOWN:{% endif %}
{% include 'emails/summary-text.html' %}
--
Cheers,
{% site_name %}

View file

@ -0,0 +1 @@
Reminder: {{ num_down }} check{{ num_down|pluralize }} still down

View file

@ -4,38 +4,14 @@
{% block content %} {% block content %}
Hello,<br /> Hello,<br />
{% if nag %} This is a {{ monthly_or_weekly }} report sent by
This is a <a href="{% site_root %}">{% site_name %}</a>.<br />
{% if nag_period == 3600 %}hourly{% endif %}
{% if nag_period == 86400 %}daily{% endif %}
reminder sent by <a href="{% site_root %}">{% site_name %}</a>.<br />
{% if num_down == 1%} {% include "emails/report-summary-html.html" %}
One check is currently <strong>DOWN</strong>:
{% else %}
{{ num_down }} checks are currently <strong>DOWN</strong>:
{% endif %}
<br />
{% include "emails/summary-html.html" %}
<strong>Too many notifications?</strong>
Visit the <a href="{{ notifications_url }}">Email Reports</a>
page on {% site_name %} to set your notification preferences.
{% else %}
This is a {{ monthly_or_weekly }} report
sent by <a href="{% site_root %}">{% site_name %}</a>.
<br />
{% include "emails/summary-downtimes-html.html" %}
<strong>Just one more thing to check:</strong> <strong>Just one more thing to check:</strong>
Do you have more cron jobs, Do you have more cron jobs, not yet on this list, that would benefit from monitoring?
not yet on this list, that would benefit from monitoring?
Get the ball rolling by adding one more! Get the ball rolling by adding one more!
{% endif %}
<br /><br /> <br /><br />
Cheers,<br> Cheers,<br>

View file

@ -1,8 +1,6 @@
{% load hc_extras %}Hello, {% load hc_extras %}Hello,
{% if nag %}This is a {% if nag_period == 3600 %}hourly {% endif %}{% if nag_period == 86400 %}daily {% endif %}reminder sent by {% site_name %}. This is a {{ monthly_or_weekly }} report sent by {% site_name %}.
{% if num_down == 1%}One check is currently DOWN:{% else %}{{ num_down }} checks are currently DOWN:{% endif %}{% else %}This is a {{ monthly_or_weekly }} report sent by {% site_name %}.{% endif %}
{% include 'emails/summary-text.html' %} {% include 'emails/summary-text.html' %}

View file

@ -1,6 +1 @@
{% if nag %}
Reminder: {{ num_down }} check{{ num_down|pluralize }} still down
{% else %}
{{ monthly_or_weekly|capfirst }} Report {{ monthly_or_weekly|capfirst }} Report
{% endif %}