use a list for recipients rather than a string

This commit is contained in:
Stephan Telling 2017-05-21 17:23:48 +02:00
parent f986617c64
commit 07029c260d
No known key found for this signature in database
GPG key ID: D4892289F36ADA9B
2 changed files with 7 additions and 12 deletions

View file

@ -49,9 +49,7 @@ def send_new_membership_email(membership):
return add_outgoing_email(
text_template='emails/new_membership_email.txt',
html_template='emails/new_membership_email.html',
recipients=', '.join(
[resp.email for resp in membership.team.responsible]
),
recipients=membership.team.responsible,
formatdict=formatdict,
subject='New membership request for {} at {}'.format(
membership.team.name,

View file

@ -66,22 +66,19 @@ def add_outgoing_email(
attachment_filename=''
):
""" adds an email to the outgoing queue
recipients is a string, if theres multiple emails seperate with a comma
recipients is a list of to recipients
"""
text_template = render_to_string(text_template, formatdict)
if html_template:
html_template = render_to_string(html_template, formatdict)
if ',' in recipients:
for recipient in recipients.split(','):
try:
validate_email(recipient.strip())
except ValidationError:
return False
else:
if not isinstance(recipients, list):
recipients = [recipients]
for recipient in recipients:
try:
validate_email(recipients)
validate_email(recipient)
except ValidationError:
return False