Send HTML confirmation emails.

Also tidy up the PDF and some of the source.
This commit is contained in:
Tom Price
2017-05-09 18:43:27 +01:00
parent f57ac3acb1
commit 1710c3f01f
5 changed files with 40 additions and 8 deletions

View File

@@ -341,7 +341,6 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix
external_styles=css).transform()
msg.attach_alternative(html, 'text/html')
msg.send()
return super(EventAuthorisationRequest, self).form_valid(form)

View File

@@ -6,8 +6,10 @@ from io import BytesIO
import reversion
from PyPDF2 import PdfFileReader, PdfFileMerger
from django.conf import settings
from django.core.mail import EmailMessage
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.mail import EmailMessage, EmailMultiAlternatives
from django.template.loader import get_template
from premailer import Premailer
from z3c.rml import rml2pdf
from RIGS import models
@@ -47,18 +49,26 @@ def send_eventauthorisation_success_email(instance):
'object': instance,
}
if instance.email == instance.event.person.email:
context['to_name'] = instance.event.person.name
subject = "N%05d | %s - Event Authorised" % (instance.event.pk, instance.event.name)
client_email = EmailMessage(
client_email = EmailMultiAlternatives(
subject,
get_template("RIGS/eventauthorisation_client_success.txt").render(context),
to=[instance.email],
reply_to=[settings.AUTHORISATION_NOTIFICATION_ADDRESS],
)
css = staticfiles_storage.path('css/email.css')
html = Premailer(get_template("RIGS/eventauthorisation_client_success.html").render(context),
external_styles=css).transform()
client_email.attach_alternative(html, 'text/html')
escapedEventName = re.sub('[^a-zA-Z0-9 \n\.]', '', instance.event.name)
client_email.attach('N%05d - %s - RECEIPT.pdf' % (instance.event.pk, escapedEventName),
client_email.attach('N%05d - %s - CONFIRMATION.pdf' % (instance.event.pk, escapedEventName),
merged.getvalue(),
'application/pdf'
)

View File

@@ -193,7 +193,7 @@
<keepTogether>
<blockTable style="totalTable" colWidths="300,115,80">
<tr>
<td>{% if not invoice %}VAT Registration Number: 170734807{% endif %}</td>
<td>{% if quote %}VAT Registration Number: 170734807{% endif %}</td>
<td>Total (ex. VAT)</td>
<td>£ {{ object.sum_total|floatformat:2 }}</td>
</tr>

View File

@@ -0,0 +1,23 @@
{% extends 'base_client_email.html' %}
{% block content %}
<div class="col-sm-12">
<p>Hi {{ to_name|default:"there" }},</p>
<p>
Your event N{{ object.event.pk|stringformat:"05d" }} has been successfully authorised
for {{ object.amount }}
by {{ object.name }} as of {{ object.last_edited_at }}.
</p>
<p>
{% if object.event.organisation and object.event.organisation.union_account %}{# internal #}
Your event is now fully booked and payment will be processed by the finance department automatically.
{% else %}{# external #}
Your event is now fully booked and our finance department will be contact to arrange payment.
{% endif %}
</p>
<p>TEC PA & Lighting</p>
</div>
{% endblock %}

View File

@@ -1,6 +1,6 @@
Hi there,
Hi {{ to_name|default:"there" }},
Just to let you know your event N{{object.event.pk|stringformat:"05d"}} has been successfully authorised for {{object.amount}} by {{object.name}} as of {{object.last_edited_at}}.
Your event N{{object.event.pk|stringformat:"05d"}} has been successfully authorised for {{object.amount}} by {{object.name}} as of {{object.last_edited_at}}.
{% if object.event.organisation and object.event.organisation.union_account %}{# internal #}
Your event is now fully booked and payment will be processed by the finance department automatically.
@@ -8,4 +8,4 @@ Your event is now fully booked and payment will be processed by the finance depa
Your event is now fully booked and our finance department will be contact to arrange payment.
{% endif %}
The TEC Rig Information Gathering System
TEC PA & Lighting