diff --git a/banquet/functions.py b/banquet/functions.py
index 02a53468..5630417e 100644
--- a/banquet/functions.py
+++ b/banquet/functions.py
@@ -1,34 +1,56 @@
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],
- fail_silently=True,
- )
+ # 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],
+ # )
+
+ # invitation.has_sent_mail = True
+ # invitation.save()
+
+ 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 +83,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,
)
diff --git a/banquet/views.py b/banquet/views.py
index 3deb2793..f2f21d23 100644
--- a/banquet/views.py
+++ b/banquet/views.py
@@ -753,7 +753,7 @@ def manage_import_invitations(request, year, banquet_pk):
if send_mail:
send_confirmation_email(
- request, invitation, invite["name"], invite["email"]
+ request, invitation, invite["name"], invite["email"], fair
)
invitation.has_sent_mail = True
@@ -885,7 +885,7 @@ def manage_invitation_form(request, year, banquet_pk, invitation_pk=None):
# Automatically send invite email if it hasn't been sent before
if send_mail and not has_sent_mail:
- send_confirmation_email(request, invitation, name, email_address)
+ send_confirmation_email(request, invitation, name, email_address, fair)
form.instance.has_sent_mail = True
form.save()
@@ -907,8 +907,10 @@ def manage_participant(request, year, banquet_pk, participant_pk):
participant = get_object_or_404(Participant, banquet=banquet, pk=participant_pk)
try:
- invitation_status = participant.invitation_set.first().status
+ invitation = participant.invitation_set.first()
+ invitation_status = invitation.status
except:
+ invitation = None
invitation_status = None
return render(
@@ -917,6 +919,7 @@ def manage_participant(request, year, banquet_pk, participant_pk):
{
"fair": fair,
"banquet": banquet,
+ "invitation": invitation,
"participant": {
"pk": participant.pk,
"name": (
@@ -1213,7 +1216,9 @@ def send_invitation_button(request, year, banquet_pk, invitation_pk):
},
)
- send_invitation_mail(invitation, name, banquet.date, banquet.location, link, email)
+ send_invitation_mail(
+ request, invitation, name, banquet.date, banquet.location, link, email, fair
+ )
return render(
request,
@@ -1614,10 +1619,12 @@ def export_participants(request, year, banquet_pk):
"Seat",
"Dietary restrictions",
"Other dietary restrictions",
+ "Dietary preferences",
"invitation",
"checked_in",
]
)
+
for participant in (
Participant.objects.select_related("seat")
.select_related("seat__table")
@@ -1633,6 +1640,7 @@ def export_participants(request, year, banquet_pk):
participant.seat,
", ".join(str(x) for x in participant.dietary_restrictions.all()),
participant.other_dietary_restrictions,
+ participant.dietary_preference,
"https://ais.armada.nu/banquet/" + participant.token,
participant.ticket_scanned,
]
diff --git a/templates/banquet/email/invitation.html b/templates/banquet/email/invitation.html
new file mode 100644
index 00000000..11cd9332
--- /dev/null
+++ b/templates/banquet/email/invitation.html
@@ -0,0 +1,30 @@
+{% extends "email/base.html" %}
+
+{% block content %}
+
+ Hello {{ name }}!
+
+
+ You have been invited to the Grand Banquet of THS Armada.
+
+{% include 'email/button.html' with content="Go to invitation" url=link %}
+{% include 'email/divider.html' %}
+
+
+ Time: {{ date|date:"Y-m-d" }} {{ date|date:"H:i" }}.
+
+
+ Location: {{ location }}.
+
+
+ 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:support@armada.nu' text='support@armada.nu' %} if you have any questions.
+
+
+
+ See you at the banquet!
+
+
+ The Banquet Team of THS Armada {{ year }}
+
+{% endblock %}
\ No newline at end of file
diff --git a/templates/banquet/manage_participant.html b/templates/banquet/manage_participant.html
index f4953e60..a65820cd 100644
--- a/templates/banquet/manage_participant.html
+++ b/templates/banquet/manage_participant.html
@@ -44,11 +44,21 @@ {{ banquet.name }} – Participant
Ticket link
- {% if banquet.background %}
- Give the following link to the participant.
-
-
+
+ {% if invitation %}
+ {% if invitation.user is None %}
+ Give the following link to the participant.
+
+ {% else %}
+ This invitation is tied to a user account. Ask {{ invitation.user.get_full_name }} to sign in to the AIS and click Banquet in the menu.
+ {% endif %}
+
+ {% if invitation.has_sent_mail %}
+ Send invitation mail (already sent)
+ {% else %}
+ Send invitation mail
+ {% endif %}
{% else %}
- Before the generated links can work, a background image needs to be uploaded (ask an IT admin) for the banquet.
+ The participant has no invitation.
{% endif %}
{% endblock %}
diff --git a/templates/banquet/participant_display.html b/templates/banquet/participant_display.html
index bb15db82..52930d83 100644
--- a/templates/banquet/participant_display.html
+++ b/templates/banquet/participant_display.html
@@ -11,11 +11,17 @@
+ {% if not participant.banquet.background %}
+ Warning: background image not uploaded!
+ {% endif %}
+