Merge pull request #395 from sartography/email-format-489

Email format #489
This commit is contained in:
Dan Funk 2021-10-12 15:51:57 -04:00 committed by GitHub
commit dc07d42a9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View File

@ -66,11 +66,11 @@ class EmailService(object):
def get_rendered_content(self, message, data): def get_rendered_content(self, message, data):
template = Template(message) template = Template(message)
rendered = template.render(data) content = template.render(data)
rendered_markdown = markdown.markdown(rendered) rendered_markdown = markdown.markdown(content, extensions=['nl2br'])
wrapped = self.get_cr_connect_wrapper(rendered_markdown) content_html = self.get_cr_connect_wrapper(rendered_markdown)
return rendered, wrapped return content, content_html
@staticmethod @staticmethod
def get_cr_connect_wrapper(email_body): def get_cr_connect_wrapper(email_body):

View File

@ -17,7 +17,11 @@ New request submitted by {{ PIComputingID }}
Email content to be delivered to {{ ApprvlApprvr1 }} Email content to be delivered to {{ ApprvlApprvr1 }}
---</bpmn:documentation> ---
**Test Some Formatting**
&amp;ensp;_UVA Tracking Number:_ {{ 321 }}
</bpmn:documentation>
<bpmn:incoming>Flow_08n2npe</bpmn:incoming> <bpmn:incoming>Flow_08n2npe</bpmn:incoming>
<bpmn:outgoing>Flow_1xlrgne</bpmn:outgoing> <bpmn:outgoing>Flow_1xlrgne</bpmn:outgoing>
<bpmn:script>subject="Camunda Email Subject" <bpmn:script>subject="Camunda Email Subject"

View File

@ -29,6 +29,9 @@ class TestEmailScript(BaseTest):
self.assertIn(task_data['ApprvlApprvr1'], outbox[0].body) self.assertIn(task_data['ApprvlApprvr1'], outbox[0].body)
self.assertIn(task_data['ApprvlApprvr1'], outbox[0].html) self.assertIn(task_data['ApprvlApprvr1'], outbox[0].html)
# Test nl2br formatting
self.assertIn('<strong>Test Some Formatting</strong><br />', outbox[0].html)
# Correct From field # Correct From field
self.assertEqual('uvacrconnect@virginia.edu', outbox[0].sender) self.assertEqual('uvacrconnect@virginia.edu', outbox[0].sender)