-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
95 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
from django.urls import reverse | ||
from django.core.mail import send_mail | ||
|
||
from util.email import send_mail | ||
|
||
def send_invitation_mail(invitation, name, date, location, link, email): | ||
|
||
def send_invitation_mail(request, invitation, name, date, location, link, email, fair): | ||
"""Send banquet invitation mail""" | ||
send_mail( | ||
"Your invite to the banquet", | ||
"Hello " | ||
+ str(name) | ||
+ "!\n" | ||
+ "You have been invited to the Grand Banquet of THS Armada.\n" | ||
+ "The banquet takes place " | ||
+ str(date) | ||
+ " at " | ||
+ str(location) | ||
+ ". \nAccess your invitation with the following link:\n" | ||
+ link | ||
+ "\n\nSee you at the banquet!\n" | ||
+ "Best Regards,\n" | ||
+ "The Banquet Team of THS Armada 2023", | ||
"Armada Banquet <[email protected]>", | ||
[email], | ||
fail_silently=True, | ||
) | ||
try: | ||
send_mail( | ||
request, | ||
template="banquet/email/invitation.html", | ||
context={ | ||
"name": name, | ||
"date": date, | ||
"location": location, | ||
"link": link, | ||
"year": fair.year, | ||
}, | ||
subject="Initial registration received!", | ||
to=[email], | ||
# file_paths=[settings.MEDIA_ROOT + signature.contract.contract.url[6:]], | ||
) | ||
except Exception as e: | ||
print("Failed to send email: ", e) | ||
return | ||
|
||
invitation.has_sent_mail = True | ||
invitation.save() | ||
|
||
|
||
def send_confirmation_email(request, invitation, name, email_address): | ||
def send_confirmation_email(request, invitation, name, email_address, fair): | ||
"""Send banquet confirmation mail""" | ||
|
||
if invitation.has_sent_mail: | ||
|
@@ -61,5 +61,12 @@ def send_confirmation_email(request, invitation, name, email_address): | |
) | ||
|
||
send_invitation_mail( | ||
invitation, name, banquet.date, banquet.location, link, email_address | ||
request, | ||
invitation, | ||
name, | ||
banquet.date, | ||
banquet.location, | ||
link, | ||
email_address, | ||
fair, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% extends "email/base.html" %} | ||
|
||
{% block content %} | ||
<p style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left"> | ||
Hello {{ name }}! | ||
</p> | ||
<p style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left"> | ||
You have been invited to the Grand Banquet of THS Armada. | ||
</p> | ||
{% include 'email/button.html' with content="Go to invitation" url=link %} | ||
{% include 'email/divider.html' %} | ||
<ul> | ||
<li style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left"> | ||
Time: {{ date|date:"Y-m-d" }} {{ date|date:"H:i" }}. | ||
</li> | ||
<li style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left"> | ||
Location: {{ location }}. | ||
</li> | ||
<li style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left"> | ||
Please note that this is an automatic email, and you cannot respond to this email. | ||
You can always reach out to {% include 'email/link.html' with url='mailto:[email protected]' text='[email protected]' %} if you have any questions. | ||
</li> | ||
</ul> | ||
<p style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left"> | ||
See you at the banquet! | ||
</p> | ||
<p style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left"> | ||
The Banquet Team of THS Armada {{ year }} | ||
</p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ def send_mail( | |
email.send() | ||
except Exception as e: | ||
print("Failed to send email: ", e) | ||
raise e |