2017-04-30 09:32:49 +00:00
|
|
|
from utils.email import add_outgoing_email
|
2017-03-23 17:32:13 +00:00
|
|
|
import logging
|
|
|
|
logger = logging.getLogger("bornhack.%s" % __name__)
|
|
|
|
|
2016-05-30 14:58:55 +00:00
|
|
|
|
2017-05-21 18:43:05 +00:00
|
|
|
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
|
|
|
|
|
2017-04-30 09:32:49 +00:00
|
|
|
# add email to outgoing email queue
|
|
|
|
return add_outgoing_email(
|
2017-04-18 18:46:57 +00:00
|
|
|
text_template='emails/creditnote_email.txt',
|
|
|
|
html_template='emails/creditnote_email.html',
|
2017-05-21 18:15:27 +00:00
|
|
|
to_recipients=creditnote.user.email,
|
2016-06-18 18:51:53 +00:00
|
|
|
formatdict=formatdict,
|
|
|
|
subject=subject,
|
|
|
|
attachment=creditnote.pdf.read(),
|
2017-04-18 18:46:57 +00:00
|
|
|
attachment_filename=creditnote.filename
|
2016-06-18 18:51:53 +00:00
|
|
|
)
|
|
|
|
|
2017-04-18 18:46:57 +00:00
|
|
|
|
2017-05-21 18:43:05 +00:00
|
|
|
def add_invoice_email(invoice):
|
2016-05-30 14:58:55 +00:00
|
|
|
# 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 14:58:55 +00:00
|
|
|
}
|
|
|
|
|
2016-05-30 16:09:21 +00:00
|
|
|
subject = 'BornHack invoice %s' % invoice.pk
|
2016-05-30 14:58:55 +00:00
|
|
|
|
2017-04-30 09:32:49 +00:00
|
|
|
# add email to outgoing email queue
|
|
|
|
return add_outgoing_email(
|
2017-04-18 18:46:57 +00:00
|
|
|
text_template='emails/invoice_email.txt',
|
|
|
|
html_template='emails/invoice_email.html',
|
2017-05-21 18:15:27 +00:00
|
|
|
to_recipients=invoice.order.user.email,
|
2016-05-30 14:58:55 +00:00
|
|
|
formatdict=formatdict,
|
|
|
|
subject=subject,
|
2016-05-30 18:50:39 +00:00
|
|
|
attachment=invoice.pdf.read(),
|
2017-04-18 18:46:57 +00:00
|
|
|
attachment_filename=invoice.filename
|
2016-05-30 14:58:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2017-05-21 18:43:05 +00:00
|
|
|
def add_test_email(recipient):
|
2017-04-30 09:32:49 +00:00
|
|
|
return add_outgoing_email(
|
2017-04-18 18:46:57 +00:00
|
|
|
text_template='emails/testmail.txt',
|
2017-05-21 18:15:27 +00:00
|
|
|
to_recipients=recipient,
|
2017-04-18 18:46:57 +00:00
|
|
|
subject='testmail from bornhack website'
|
2016-05-30 14:58:55 +00:00
|
|
|
)
|