From 2ba70c692f0b6fc00348f220ba0ca007476c4a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Thu, 8 Aug 2019 10:26:47 +0200 Subject: [PATCH] Remove multiple attachment code - was not even done --- src/utils/email.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/utils/email.py b/src/utils/email.py index 6fdcd770..e172c87f 100644 --- a/src/utils/email.py +++ b/src/utils/email.py @@ -20,7 +20,6 @@ def _send_email( sender="BornHack ", attachment=None, attachment_filename="", - attachments=None, ): if not isinstance(to_recipients, list): to_recipients = [to_recipients] @@ -42,15 +41,11 @@ def _send_email( if html_template: msg.attach_alternative(html_template, "text/html") - if not attachments and attachment: - attachments = [(attachment, attachment_filename)] - # is there an attachment to this mail? - if attachments: - for content, filename in attachments: - # figure out the mimetype - mimetype = magic.from_buffer(content, mime=True) - msg.attach(filename, content, mimetype) + if attachment + # figure out the mimetype + mimetype = magic.from_buffer(attachment, mime=True) + msg.attach(attachment_filename, attachment, mimetype) except Exception as e: logger.exception("exception while rendering email: {}".format(e)) return False @@ -76,6 +71,7 @@ def add_outgoing_email( sender="BornHack ", attachment=None, attachment_filename="", + attachments=None, ): """ adds an email to the outgoing queue recipients is a list of to recipients @@ -104,9 +100,4 @@ def add_outgoing_email( bcc_recipients=bcc_recipients, ) - if attachment: - django_file = ContentFile(attachment) - django_file.name = attachment_filename - email.attachment.save(attachment_filename, django_file, save=True) - return True