Postmark: Fix Postmark error on empty subject/body with template_id.

Postmark issues an error if Django's default empty strings are used
with template sends.

Include template send in Postmark integration tests. (Requires real
Postmark API token -- templates aren't testable with Postmark's
sandbox token.)

Fixes #121
This commit is contained in:
medmunds
2018-09-05 12:41:33 -07:00
parent 8b7b833a2b
commit 753c895301
5 changed files with 53 additions and 21 deletions

View File

@@ -198,6 +198,11 @@ class PostmarkPayload(RequestsPayload):
def set_template_id(self, template_id):
self.data["TemplateId"] = template_id
# Subject, TextBody, and HtmlBody aren't allowed with TemplateId;
# delete Django default subject and body empty strings:
for field in ("Subject", "TextBody", "HtmlBody"):
if field in self.data and not self.data[field]:
del self.data[field]
# merge_data: Postmark doesn't support per-recipient substitutions