Browse Source

Email alerts and monthly reports have links to Log pages.

Don't show ping URLs -- gmail converts them to clickable links, and people click on them.
pull/50/head
Pēteris Caune 9 years ago
parent
commit
da613963e9
4 changed files with 25 additions and 8 deletions
  1. +15
    -0
      hc/accounts/tests/test_profile.py
  2. +3
    -0
      hc/api/models.py
  3. +4
    -4
      templates/emails/alert-body-html.html
  4. +3
    -4
      templates/emails/report-body-html.html

+ 15
- 0
hc/accounts/tests/test_profile.py View File

@ -2,6 +2,7 @@ from django.core import mail
from hc.test import BaseTestCase from hc.test import BaseTestCase
from hc.accounts.models import Profile from hc.accounts.models import Profile
from hc.api.models import Check
class LoginTestCase(BaseTestCase): class LoginTestCase(BaseTestCase):
@ -41,3 +42,17 @@ class LoginTestCase(BaseTestCase):
profile = Profile.objects.for_user(self.alice) profile = Profile.objects.for_user(self.alice)
self.assertEqual(profile.api_key, "") 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)

+ 3
- 0
hc/api/models.py View File

@ -61,6 +61,9 @@ class Check(models.Model):
def url(self): def url(self):
return settings.PING_ENDPOINT + str(self.code) return settings.PING_ENDPOINT + str(self.code)
def log_url(self):
return settings.SITE_ROOT + reverse("hc-log", args=[self.code])
def email(self): def email(self):
return "%s@%s" % (self.code, settings.PING_EMAIL_DOMAIN) return "%s@%s" % (self.code, settings.PING_EMAIL_DOMAIN)


+ 4
- 4
templates/emails/alert-body-html.html View File

@ -41,9 +41,9 @@
<tr> <tr>
<th></th> <th></th>
<th>Name</th> <th>Name</th>
<th>URL</th>
<th>Period</th> <th>Period</th>
<th>Last Ping</th> <th>Last Ping</th>
<th>Actions</th>
</tr> </tr>
{% for check in checks %} {% for check in checks %}
<tr> <tr>
@ -71,9 +71,6 @@
<small>{{ check.tags }}</small> <small>{{ check.tags }}</small>
{% endif %} {% endif %}
</td> </td>
<td class="url-cell">
<code>{{ check.url }}</code>
</td>
<td> <td>
{{ check.timeout|hc_duration }} {{ check.timeout|hc_duration }}
</td> </td>
@ -84,6 +81,9 @@
Never Never
{% endif %} {% endif %}
</td> </td>
<td>
<a href="{{ check.log_url }}">View Log</a>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>


+ 3
- 4
templates/emails/report-body-html.html View File

@ -39,7 +39,6 @@
<tr> <tr>
<th></th> <th></th>
<th>Name</th> <th>Name</th>
<th>URL</th>
<th>Period</th> <th>Period</th>
<th>Last Ping</th> <th>Last Ping</th>
</tr> </tr>
@ -69,9 +68,6 @@
<small>{{ check.tags }}</small> <small>{{ check.tags }}</small>
{% endif %} {% endif %}
</td> </td>
<td class="url-cell">
<code>{{ check.url }}</code>
</td>
<td> <td>
{{ check.timeout|hc_duration }} {{ check.timeout|hc_duration }}
</td> </td>
@ -82,6 +78,9 @@
Never Never
{% endif %} {% endif %}
</td> </td>
<td>
<a href="{{ check.log_url }}">View Log</a>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>


Loading…
Cancel
Save