From f565a4c294302ca41d548d2cbad9c4ebc251faa4 Mon Sep 17 00:00:00 2001 From: medmunds Date: Sat, 19 Oct 2013 11:41:20 -0700 Subject: [PATCH] Mandrill requires template_content field for send-template. Fixes #47. --- djrill/mail/backends/djrill.py | 5 ++--- djrill/tests/test_mandrill_send_template.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/djrill/mail/backends/djrill.py b/djrill/mail/backends/djrill.py index 0828b37..7998ac4 100644 --- a/djrill/mail/backends/djrill.py +++ b/djrill/mail/backends/djrill.py @@ -76,9 +76,8 @@ class DjrillBackend(BaseEmailBackend): if hasattr(message, 'template_name'): api_url = self.api_send_template api_params['template_name'] = message.template_name - if hasattr(message, 'template_content'): - api_params['template_content'] = \ - self._expand_merge_vars(message.template_content) + api_params['template_content'] = \ + self._expand_merge_vars(getattr(message, 'template_content', {})) response = requests.post(api_url, data=json.dumps(api_params)) diff --git a/djrill/tests/test_mandrill_send_template.py b/djrill/tests/test_mandrill_send_template.py index 51d0190..ed987b9 100644 --- a/djrill/tests/test_mandrill_send_template.py +++ b/djrill/tests/test_mandrill_send_template.py @@ -36,7 +36,7 @@ class DjrillMandrillSendTemplateTests(DjrillBackendMockAPITestCase): self.assert_mandrill_called("/messages/send-template.json") data = self.get_api_call_data() self.assertEqual(data['template_name'], "WELCOME_MESSAGE") - self.assertFalse('template_content' in data) + self.assertEqual(data['template_content'], []) # Mandrill requires this field def test_non_template_send(self): # Make sure the non-template case still uses /messages/send.json