Fix #531 -- Make placeholders replace in subject (#594)

Placeholders in subject were not being replaced because there was
no `.format()` called on the subject.

This commit creates a context dict that is used for both the body
and the subject. It is then replaced using `.format_map()`

Fixes https://github.com/pretix/pretix/issues/531
This commit is contained in:
Sanket Dasgupta
2017-10-07 21:46:13 +05:30
committed by Raphael Michel
parent 96dd4e02f3
commit 58938fc07c
5 changed files with 55 additions and 14 deletions

View File

@@ -82,6 +82,7 @@ def mail(email: str, subject: str, template: Union[str, LazyI18nString],
'invoice_company': ''
})
body, body_md = render_mail(template, context)
subject = str(subject).format_map(context)
sender = sender or (event.settings.get('mail_from') if event else settings.MAIL_FROM)
subject = str(subject)