diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index db95b34f..49fea2cb 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -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) diff --git a/RIGS/signals.py b/RIGS/signals.py index 6aac2388..df5dc8fe 100644 --- a/RIGS/signals.py +++ b/RIGS/signals.py @@ -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' ) diff --git a/RIGS/templates/RIGS/event_print_page.xml b/RIGS/templates/RIGS/event_print_page.xml index 422c3c5e..27317c57 100644 --- a/RIGS/templates/RIGS/event_print_page.xml +++ b/RIGS/templates/RIGS/event_print_page.xml @@ -193,7 +193,7 @@ - {% if not invoice %}VAT Registration Number: 170734807{% endif %} + {% if quote %}VAT Registration Number: 170734807{% endif %} Total (ex. VAT) £ {{ object.sum_total|floatformat:2 }} diff --git a/RIGS/templates/RIGS/eventauthorisation_client_success.html b/RIGS/templates/RIGS/eventauthorisation_client_success.html new file mode 100644 index 00000000..cccf8b4a --- /dev/null +++ b/RIGS/templates/RIGS/eventauthorisation_client_success.html @@ -0,0 +1,23 @@ +{% extends 'base_client_email.html' %} + +{% block content %} +
+

Hi {{ to_name|default:"there" }},

+ +

+ 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. + {% else %}{# external #} + Your event is now fully booked and our finance department will be contact to arrange payment. + {% endif %} +

+ +

TEC PA & Lighting

+
+{% endblock %} diff --git a/RIGS/templates/RIGS/eventauthorisation_client_success.txt b/RIGS/templates/RIGS/eventauthorisation_client_success.txt index 23e05786..693ba7ac 100644 --- a/RIGS/templates/RIGS/eventauthorisation_client_success.txt +++ b/RIGS/templates/RIGS/eventauthorisation_client_success.txt @@ -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