bornhack-website/src/sponsors/email.py
Thomas Steen Rasmussen 00af109e2f
add flake8 and isort to pre-commit config, make flake8 and isort happy (#441)
* add flake8 to pre-commit config, and fixup many things to make flake8 happy

* add isort and sort all imports, add to pre-commit and requirements
2020-02-12 13:10:41 +01:00

35 lines
952 B
Python

import logging
import os
from django.conf import settings
from utils.email import add_outgoing_email
logger = logging.getLogger("bornhack.%s" % __name__)
def add_sponsorticket_email(ticket):
# put formatdict together
formatdict = {
"ticket": ticket,
}
subject = "%s %s Sponsor Ticket %s" % (
ticket.sponsor.camp.title,
ticket.sponsor.name,
ticket.uuid,
)
filename = "sponsor_ticket_{}.pdf".format(ticket.pk)
with open(os.path.join(settings.PDF_ARCHIVE_PATH, filename), "rb") as f:
# add email to outgoing email queue
return add_outgoing_email(
text_template="emails/sponsorticket_email.txt",
html_template="emails/sponsorticket_email.html",
to_recipients=ticket.sponsor.ticket_email,
formatdict=formatdict,
subject=subject,
attachment=f.read(),
attachment_filename=filename,
)