email sponsor tickets one by one
This commit is contained in:
parent
38b7cae7d7
commit
7f95f41055
|
@ -1,25 +1,27 @@
|
||||||
from utils.email import add_outgoing_email
|
from utils.email import add_outgoing_email
|
||||||
|
|
||||||
|
|
||||||
def add_sponsorticket_email(sponsor):
|
def add_sponsorticket_email(ticket):
|
||||||
# put formatdict together
|
# put formatdict together
|
||||||
formatdict = {
|
formatdict = {
|
||||||
"sponsor": sponsor,
|
"ticket": ticket,
|
||||||
}
|
}
|
||||||
|
|
||||||
subject = "BornHack %s Sponsor Tickets" % sponsor.camp.title
|
subject = "BornHack %s Sponsor Ticket %s" % (
|
||||||
attachments = []
|
ticket.sponsor.camp.title,
|
||||||
for ticket in sponsor.sponsorticket_set.all():
|
ticket.uuid,
|
||||||
path = "sponsor_ticket_%s" % ticket.uuid
|
|
||||||
attachments.append()
|
|
||||||
|
|
||||||
# add email to outgoing email queue
|
|
||||||
return add_outgoing_email(
|
|
||||||
text_template="emails/sponsorticket_email.txt",
|
|
||||||
html_template="emails/sponsorticket_email.html",
|
|
||||||
to_recipients=sponsor.ticket_email,
|
|
||||||
formatdict=formatdict,
|
|
||||||
subject=subject,
|
|
||||||
attachments=attachments
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
filename = "sponsor_ticket_{}.pdf".format(ticket.pk)
|
||||||
|
with open(os.path.join(settings.PDF_ARCHIVE_PATH, filename)) 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=sponsor.ticket_email,
|
||||||
|
formatdict=formatdict,
|
||||||
|
subject=subject,
|
||||||
|
attachment=f.read(),
|
||||||
|
attachment_filename=filename,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,14 @@ class Command(BaseCommand):
|
||||||
sponsor.ticket_ready and
|
sponsor.ticket_ready and
|
||||||
not sponsor.tickets_sent
|
not sponsor.tickets_sent
|
||||||
):
|
):
|
||||||
self.output("# Generating outgoing email to send tickets for {}:".format(sponsor))
|
self.output("# Generating outgoing emails to send tickets for {}:".format(sponsor))
|
||||||
# send the email
|
for ticket in sponsor.sponsorticket_set.all():
|
||||||
if add_sponsorticket_email(sponsor=sponsor):
|
# send the email
|
||||||
logger.info("OK: email to %s added" % sponsor)
|
if add_sponsorticket_email(ticket=ticket):
|
||||||
sponsor.tickets_sent = True
|
logger.info("OK: email to %s added" % sponsor)
|
||||||
sponsor.save()
|
else:
|
||||||
else:
|
logger.error("Unable to send sponsor ticket email to %s" % sponsor)
|
||||||
logger.error("Unable to send sponsor ticket email to %s" % sponsor)
|
|
||||||
|
sponsor.tickets_sent = True
|
||||||
|
sponsor.save()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Hello!<br>
|
Hello!<br>
|
||||||
<br>
|
<br>
|
||||||
This email contains the {{ sponsor.name }} sponsor tickets for {{ sponsor.camp.title }}<br>
|
This email contains a {{ ticket.sponsor.name }} sponsor ticket for {{ ticket.sponsor.camp.title }}<br>
|
||||||
Thank you for helping out! :)<br>
|
Thank you for helping out! :)<br>
|
||||||
<br>
|
<br>
|
||||||
Best regards,<br>
|
Best regards,<br>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Hello!
|
Hello!
|
||||||
|
|
||||||
This email contains the {{ sponsor.name }} sponsor tickets for {{ sponsor.camp.title }}
|
This email contains a {{ ticket.sponsor.name }} sponsor ticket for {{ ticket.sponsor.camp.title }}
|
||||||
Thank you for helping out! :)
|
Thank you for helping out! :)
|
||||||
|
|
||||||
Best regards,
|
Best regards,
|
||||||
|
|
Loading…
Reference in a new issue