mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
prepare for PR to mainstream (tests, docs, ...)
This commit is contained in:
@@ -313,6 +313,7 @@ class DjrillBackend(BaseEmailBackend):
|
|||||||
return mandrill_attachment, is_embedded_image
|
return mandrill_attachment, is_embedded_image
|
||||||
|
|
||||||
def _filter_msg_dict(self, message, msg_dict):
|
def _filter_msg_dict(self, message, msg_dict):
|
||||||
|
"""Filter message data (e.g. clear subject field, or from field)"""
|
||||||
if hasattr(message, 'clear_from') and message.clear_from:
|
if hasattr(message, 'clear_from') and message.clear_from:
|
||||||
msg_dict['from_name'] = ''
|
msg_dict['from_name'] = ''
|
||||||
msg_dict['from_email'] = ''
|
msg_dict['from_email'] = ''
|
||||||
|
|||||||
@@ -27,6 +27,21 @@ class DjrillMandrillSendTemplateTests(DjrillBackendMockAPITestCase):
|
|||||||
'content': "<p><em>Half off</em> all fruit</p>"} ]
|
'content': "<p><em>Half off</em> all fruit</p>"} ]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_send_template_without_from_field(self):
|
||||||
|
msg = mail.EmailMessage('Subject', 'Text Body',
|
||||||
|
'from@example.com', ['to@example.com'])
|
||||||
|
msg.template_name = "PERSONALIZED_SPECIALS"
|
||||||
|
msg.clear_from = True
|
||||||
|
msg.clear_subject = True
|
||||||
|
msg.send()
|
||||||
|
self.assert_mandrill_called("/messages/send-template.json")
|
||||||
|
data = self.get_api_call_data()
|
||||||
|
print data
|
||||||
|
self.assertEqual(data['template_name'], "PERSONALIZED_SPECIALS")
|
||||||
|
self.assertEqual(data['message']['subject'], "")
|
||||||
|
self.assertEqual(data['message']['from_email'], "")
|
||||||
|
self.assertEqual(data['message']['from_name'], "")
|
||||||
|
|
||||||
def test_no_template_content(self):
|
def test_no_template_content(self):
|
||||||
# Just a template, without any template_content to be merged
|
# Just a template, without any template_content to be merged
|
||||||
msg = mail.EmailMessage('Subject', 'Text Body',
|
msg = mail.EmailMessage('Subject', 'Text Body',
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ can be used with templates.
|
|||||||
|
|
||||||
How To Use Default Mandrill Subject and From fields
|
How To Use Default Mandrill Subject and From fields
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
.. versionadded:: dev
|
|
||||||
Mandrill default fields support
|
|
||||||
|
|
||||||
To use default *Mandril* subject or default from field you need send message
|
To use default *Mandril* subject or default from field you need send message
|
||||||
to *Mandril* with empty subject or empty from field. This can be done using
|
to *Mandril* with empty subject or empty from field. This can be done using
|
||||||
|
|||||||
Reference in New Issue
Block a user