Browse Source

Add a "Subject" field in the "Ping Details" dialog

pull/485/head
Pēteris Caune 4 years ago
parent
commit
2a63d24812
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 24 additions and 0 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +13
    -0
      hc/front/tests/test_ping_details.py
  3. +1
    -0
      hc/front/views.py
  4. +9
    -0
      templates/front/ping_details.html

+ 1
- 0
CHANGELOG.md View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
## Improvements
- Rename VictorOps -> Splunk On-Call
- Implement email body decoding in the "Ping Details" dialog
- Add a "Subject" field in the "Ping Details" dialog
## Bug Fixes
- Fix downtime summary to handle months when the check didn't exist yet (#472)


+ 13
- 0
hc/front/tests/test_ping_details.py View File

@ -142,3 +142,16 @@ class PingDetailsTestCase(BaseTestCase):
# PGI+aGVsbG88L2I+ is base64("<b>hello</b>")
self.assertContains(r, "PGI+aGVsbG88L2I+")
self.assertContains(r, "&lt;b&gt;hello&lt;/b&gt;")
def test_it_decodes_email_subject(self):
Ping.objects.create(
owner=self.check,
scheme="email",
body="Subject: =?UTF-8?B?aGVsbG8gd29ybGQ=?=",
)
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url)
# aGVsbG8gd29ybGQ= is base64("hello world")
self.assertContains(r, "hello world", status_code=200)

+ 1
- 0
hc/front/views.py View File

@ -512,6 +512,7 @@ def ping_details(request, code, n=None):
if ping.scheme == "email":
parsed = email.message_from_string(ping.body, policy=email.policy.SMTP)
ctx["subject"] = parsed.get("subject", "")
plain_mime_part = parsed.get_body(("plain",))
if plain_mime_part:


+ 9
- 0
templates/front/ping_details.html View File

@ -62,6 +62,15 @@
</p>
</div>
{% endif %}
{% if subject %}
<div class="col-sm-12">
<p>
<strong>Subject</strong>
<span>{{ subject }}</span>
</p>
</div>
{% endif %}
</div>
{% if ping.body %}


Loading…
Cancel
Save