mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-08 07:59:42 +00:00
Add test for sending emails.
Add backup email if there isn't an MIC
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import reversion
|
||||
from django.conf import settings
|
||||
|
||||
from django.core.mail import EmailMessage
|
||||
from django.template.loader import get_template
|
||||
@@ -15,10 +16,16 @@ def send_eventauthorisation_success_email(instance):
|
||||
get_template("RIGS/eventauthorisation_client_success.txt").render(context),
|
||||
to=[instance.email]
|
||||
)
|
||||
|
||||
if instance.event.mic:
|
||||
mic_email_address = instance.event.mic.email
|
||||
else:
|
||||
mic_email_address = settings.AUTHORISATION_NOTIFICATION_ADDRESS
|
||||
|
||||
mic_email = EmailMessage(
|
||||
"N%05d | %s - Event Authorised".format(instance.event.pk, instance.event.name),
|
||||
get_template("RIGS/eventauthorisation_mic_success.txt").render(context),
|
||||
to=[instance.event.mic.email]
|
||||
to=[mic_email_address]
|
||||
)
|
||||
|
||||
client_email.send()
|
||||
|
||||
Reference in New Issue
Block a user