mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Merge branch 'send-template' of git://github.com/peillis/Djrill into send_template
This commit is contained in:
@@ -48,6 +48,7 @@ class DjrillBackend(BaseEmailBackend):
|
|||||||
"in the settings.py file.")
|
"in the settings.py file.")
|
||||||
|
|
||||||
self.api_action = self.api_url + "/messages/send.json"
|
self.api_action = self.api_url + "/messages/send.json"
|
||||||
|
self.template_api_action = self.api_url + "/messages/send-template.json"
|
||||||
|
|
||||||
def send_messages(self, email_messages):
|
def send_messages(self, email_messages):
|
||||||
if not email_messages:
|
if not email_messages:
|
||||||
@@ -77,6 +78,19 @@ class DjrillBackend(BaseEmailBackend):
|
|||||||
raise
|
raise
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# check if template is set in message to send it via
|
||||||
|
# api url: /messages/send-template.json
|
||||||
|
if hasattr(message, 'template_name'):
|
||||||
|
template_content = getattr(message, 'template_content',
|
||||||
|
None)
|
||||||
|
djrill_it = requests.post(self.template_api_action,
|
||||||
|
data=json.dumps({
|
||||||
|
"key": self.api_key,
|
||||||
|
"template_name": message.template_name,
|
||||||
|
"template_content": template_content,
|
||||||
|
"message": msg_dict
|
||||||
|
}))
|
||||||
|
else:
|
||||||
djrill_it = requests.post(self.api_action, data=json.dumps({
|
djrill_it = requests.post(self.api_action, data=json.dumps({
|
||||||
"key": self.api_key,
|
"key": self.api_key,
|
||||||
"message": msg_dict
|
"message": msg_dict
|
||||||
|
|||||||
Reference in New Issue
Block a user