Browse Source

Update report templates for weekly reports

pull/522/head
Pēteris Caune 3 years ago
parent
commit
a0cd2c63e9
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
  1. 1
      hc/accounts/models.py
  2. 19
      hc/api/tests/test_sendreports.py
  3. 3
      templates/emails/report-body-html.html
  4. 2
      templates/emails/report-body-text.html
  5. 2
      templates/emails/report-subject.html

1
hc/accounts/models.py

@ -214,6 +214,7 @@ class Profile(models.Model):
"nag_period": self.nag_period.total_seconds(),
"num_down": num_down,
"month_boundaries": boundaries,
"monthly_or_weekly": self.reports,
}
emails.report(self.user.email, ctx, headers)

19
hc/api/tests/test_sendreports.py

@ -33,7 +33,7 @@ class SendReportsTestCase(BaseTestCase):
self.check.status = "down"
self.check.save()
def test_it_sends_report(self):
def test_it_sends_monthly_report(self):
cmd = Command(stdout=Mock())
cmd.pause = Mock() # don't pause for 1s
@ -48,6 +48,23 @@ class SendReportsTestCase(BaseTestCase):
email = mail.outbox[0]
self.assertTrue("List-Unsubscribe" in email.extra_headers)
self.assertTrue("List-Unsubscribe-Post" in email.extra_headers)
self.assertEqual(email.subject, "Monthly Report")
self.assertIn("This is a monthly report", email.body)
self.assertIn("This is a monthly report", email.alternatives[0][0])
def test_it_sends_weekly_report(self):
self.profile.reports = "weekly"
self.profile.save()
cmd = Command(stdout=Mock())
cmd.pause = Mock() # don't pause for 1s
cmd.handle_one_report()
email = mail.outbox[0]
self.assertEqual(email.subject, "Weekly Report")
self.assertIn("This is a weekly report", email.body)
self.assertIn("This is a weekly report", email.alternatives[0][0])
def test_it_obeys_next_report_date(self):
self.profile.next_report_date = now() + td(days=1)

3
templates/emails/report-body-html.html

@ -24,7 +24,8 @@ Hello,<br />
page on {% site_name %} to set your notification preferences.
{% else %}
This is a monthly report sent by <a href="{% site_root %}">{% site_name %}</a>.
This is a {{ monthly_or_weekly }} report
sent by <a href="{% site_root %}">{% site_name %}</a>.
<br />
{% include "emails/summary-downtimes-html.html" %}

2
templates/emails/report-body-text.html

@ -3,7 +3,7 @@ Hello,
{% if nag %}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 %}{% else %}This is a monthly report sent by {% site_name %}.{% endif %}
{% 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' %}

2
templates/emails/report-subject.html

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