diff --git a/hc/accounts/models.py b/hc/accounts/models.py
index 1a9b3d56..52167d2f 100644
--- a/hc/accounts/models.py
+++ b/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)
diff --git a/hc/api/tests/test_sendreports.py b/hc/api/tests/test_sendreports.py
index fece30ad..d675ee97 100644
--- a/hc/api/tests/test_sendreports.py
+++ b/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)
diff --git a/templates/emails/report-body-html.html b/templates/emails/report-body-html.html
index 033c7b28..b5044d4c 100644
--- a/templates/emails/report-body-html.html
+++ b/templates/emails/report-body-html.html
@@ -24,7 +24,8 @@ Hello,
page on {% site_name %} to set your notification preferences.
{% else %}
- This is a monthly report sent by {% site_name %}.
+ This is a {{ monthly_or_weekly }} report
+ sent by {% site_name %}.
{% include "emails/summary-downtimes-html.html" %}
diff --git a/templates/emails/report-body-text.html b/templates/emails/report-body-text.html
index 8bfc9f7c..69c9aca6 100644
--- a/templates/emails/report-body-text.html
+++ b/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' %}
diff --git a/templates/emails/report-subject.html b/templates/emails/report-subject.html
index 9671b5ee..0412f585 100644
--- a/templates/emails/report-subject.html
+++ b/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 %}