bornhack-website/src/shop/email.py

54 lines
1.5 KiB
Python
Raw Normal View History

from utils.email import add_outgoing_email
2017-03-23 17:32:13 +00:00
import logging
logger = logging.getLogger("bornhack.%s" % __name__)
def add_creditnote_email(creditnote):
2016-06-18 18:51:53 +00:00
# put formatdict together
formatdict = {
'creditnote': creditnote,
}
subject = 'BornHack creditnote %s' % creditnote.pk
# add email to outgoing email queue
return add_outgoing_email(
text_template='emails/creditnote_email.txt',
html_template='emails/creditnote_email.html',
to_recipients=creditnote.user.email,
2016-06-18 18:51:53 +00:00
formatdict=formatdict,
subject=subject,
attachment=creditnote.pdf.read(),
attachment_filename=creditnote.filename
2016-06-18 18:51:53 +00:00
)
def add_invoice_email(invoice):
# put formatdict together
formatdict = {
2016-05-30 16:09:21 +00:00
'ordernumber': invoice.order.pk,
'invoicenumber': invoice.pk,
'filename': invoice.filename,
}
2016-05-30 16:09:21 +00:00
subject = 'BornHack invoice %s' % invoice.pk
# add email to outgoing email queue
return add_outgoing_email(
text_template='emails/invoice_email.txt',
html_template='emails/invoice_email.html',
to_recipients=invoice.order.user.email,
formatdict=formatdict,
subject=subject,
attachment=invoice.pdf.read(),
attachment_filename=invoice.filename
)
def add_test_email(recipient):
return add_outgoing_email(
text_template='emails/testmail.txt',
to_recipients=recipient,
subject='testmail from bornhack website'
)