diff --git a/hc/accounts/tests/test_profile.py b/hc/accounts/tests/test_profile.py index e3cdd6e6..43dc2452 100644 --- a/hc/accounts/tests/test_profile.py +++ b/hc/accounts/tests/test_profile.py @@ -2,6 +2,7 @@ from django.core import mail from hc.test import BaseTestCase from hc.accounts.models import Profile +from hc.api.models import Check class LoginTestCase(BaseTestCase): @@ -41,3 +42,17 @@ class LoginTestCase(BaseTestCase): profile = Profile.objects.for_user(self.alice) self.assertEqual(profile.api_key, "") + + def test_it_sends_report(self): + check = Check(name="Test Check", user=self.alice) + check.save() + + profile = Profile.objects.for_user(self.alice) + profile.send_report() + + # And an email should have been sent + self.assertEqual(len(mail.outbox), 1) + message = mail.outbox[0] + + self.assertEqual(message.subject, 'Monthly Report') + self.assertIn("Test Check", message.body) diff --git a/hc/api/models.py b/hc/api/models.py index 6edad11c..80559dcb 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -61,6 +61,9 @@ class Check(models.Model): def url(self): return settings.PING_ENDPOINT + str(self.code) + def log_url(self): + return settings.SITE_ROOT + reverse("hc-log", args=[self.code]) + def email(self): return "%s@%s" % (self.code, settings.PING_EMAIL_DOMAIN) diff --git a/templates/emails/alert-body-html.html b/templates/emails/alert-body-html.html index ba621494..d4ed9f2d 100644 --- a/templates/emails/alert-body-html.html +++ b/templates/emails/alert-body-html.html @@ -41,9 +41,9 @@ Name - URL Period Last Ping + Actions {% for check in checks %} @@ -71,9 +71,6 @@ {{ check.tags }} {% endif %} - - {{ check.url }} - {{ check.timeout|hc_duration }} @@ -84,6 +81,9 @@ Never {% endif %} + + View Log + {% endfor %} diff --git a/templates/emails/report-body-html.html b/templates/emails/report-body-html.html index 6501426b..dcf780e1 100644 --- a/templates/emails/report-body-html.html +++ b/templates/emails/report-body-html.html @@ -39,7 +39,6 @@ Name - URL Period Last Ping @@ -69,9 +68,6 @@ {{ check.tags }} {% endif %} - - {{ check.url }} - {{ check.timeout|hc_duration }} @@ -82,6 +78,9 @@ Never {% endif %} + + View Log + {% endfor %}