From 5df8f127c77fa4282dc1c8bc025df0b73a1a1610 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 8 Oct 2021 11:26:30 -0400 Subject: [PATCH 1/2] Fix email formatting. Markdown was swallowing the carriage returns. We use the nl2br extension now. --- crc/services/email_service.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crc/services/email_service.py b/crc/services/email_service.py index d90b580c..66b9b0ac 100644 --- a/crc/services/email_service.py +++ b/crc/services/email_service.py @@ -64,11 +64,11 @@ class EmailService(object): def get_rendered_content(self, message, data): template = Template(message) - rendered = template.render(data) - rendered_markdown = markdown.markdown(rendered) - wrapped = self.get_cr_connect_wrapper(rendered_markdown) + content = template.render(data) + rendered_markdown = markdown.markdown(content, extensions=['nl2br']) + content_html = self.get_cr_connect_wrapper(rendered_markdown) - return rendered, wrapped + return content, content_html @staticmethod def get_cr_connect_wrapper(email_body): From 1fb298f796bc71ceb10432491dd591839103a2d2 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 8 Oct 2021 11:26:54 -0400 Subject: [PATCH 2/2] Test for the new formatting --- tests/data/email/email.bpmn | 8 ++++++-- tests/emails/test_email_script.py | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/data/email/email.bpmn b/tests/data/email/email.bpmn index bd9b7d8c..d1e95714 100644 --- a/tests/data/email/email.bpmn +++ b/tests/data/email/email.bpmn @@ -1,5 +1,5 @@ - + Flow_1synsig @@ -17,7 +17,11 @@ New request submitted by {{ PIComputingID }} Email content to be delivered to {{ ApprvlApprvr1 }} ---- +--- +**Test Some Formatting** + _UVA Tracking Number:_ {{ 321 }} + + Flow_08n2npe Flow_1xlrgne subject="Camunda Email Subject" diff --git a/tests/emails/test_email_script.py b/tests/emails/test_email_script.py index d09ae87a..6ceccf1f 100644 --- a/tests/emails/test_email_script.py +++ b/tests/emails/test_email_script.py @@ -29,6 +29,9 @@ class TestEmailScript(BaseTest): self.assertIn(task_data['ApprvlApprvr1'], outbox[0].body) self.assertIn(task_data['ApprvlApprvr1'], outbox[0].html) + # Test nl2br formatting + self.assertIn('Test Some Formatting
', outbox[0].html) + # Correct From field self.assertEqual('uvacrconnect@virginia.edu', outbox[0].sender)