diff --git a/src/utils/admin.py b/src/utils/admin.py index 92a7826a..a866181b 100644 --- a/src/utils/admin.py +++ b/src/utils/admin.py @@ -3,6 +3,7 @@ from django.contrib import admin from .models import OutgoingEmail +@admin.register(OutgoingEmail) class OutgoingEmailAdmin(admin.ModelAdmin): model = OutgoingEmail - fields = ['subject', 'to_recipients'] \ No newline at end of file + fields = ['subject', 'to_recipients'] diff --git a/src/utils/email.py b/src/utils/email.py index ad79b36e..67821bf4 100644 --- a/src/utils/email.py +++ b/src/utils/email.py @@ -71,7 +71,6 @@ 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 @@ -100,4 +99,9 @@ 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