Skip to content

Commit

Permalink
Add last minute banquet changes
Browse files Browse the repository at this point in the history
  • Loading branch information
didrikmunther committed Oct 2, 2024
1 parent 8bbfa4d commit 1f2f75a
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 13 deletions.
7 changes: 7 additions & 0 deletions banquet/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import re
import csv

from people.models import DietaryRestriction

from .models import (
DietaryPreference,
Participant,
Expand Down Expand Up @@ -66,6 +68,11 @@ def __init__(self, *args, **kwargs):
banquet
)

self.fields["dietary_restrictions"].queryset = self.get_dietary_restrictions()

def get_dietary_restrictions(self):
return DietaryRestriction.objects.filter(show_in_banquet=True)

def get_dietary_preferences(self, banquet):
# Custom function to retrieve dietary preferences for the given banquet
return DietaryPreference.objects.filter(banquet=banquet)
Expand Down
12 changes: 6 additions & 6 deletions banquet/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
from util.email import send_mail


def send_invitation_mail(request, invitation, name, date, location, link, email, fair):
def send_invitation_mail(request, invitation, name, banquet, link, email, fair):
"""Send banquet invitation mail"""
try:
send_mail(
request,
template="banquet/email/invitation.html",
context={
"name": name,
"date": date,
"location": location,
"date": banquet.date,
"location": banquet.location,
"dress_code": banquet.dress_code,
"link": link,
"year": fair.year,
},
subject="Initial registration received!",
subject="THS Armada Banquet Invitation",
to=[email],
# file_paths=[settings.MEDIA_ROOT + signature.contract.contract.url[6:]],
)
Expand Down Expand Up @@ -64,8 +65,7 @@ def send_confirmation_email(request, invitation, name, email_address, fair):
request,
invitation,
name,
banquet.date,
banquet.location,
banquet,
link,
email_address,
fair,
Expand Down
16 changes: 15 additions & 1 deletion banquet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,13 @@ def manage_participant(request, year, banquet_pk, participant_pk):
)


def get_dietary_string(participant):
dietary_restrictions = participant.dietary_restrictions
if dietary_restrictions.count() == 0:
return participant.dietary_preference
return f"{participant.dietary_preference} ({', '.join(dietary_restrictions.values_list('name', flat=True))})"


@permission_required("banquet.base")
def manage_participants(request, year, banquet_pk):
fair = get_object_or_404(Fair, year=year)
Expand All @@ -980,6 +987,7 @@ def manage_participants(request, year, banquet_pk):
if participant.user
else participant.email_address
),
"dietary": get_dietary_string(participant),
"alcohol": participant.alcohol,
"seat": participant.seat,
"invitation": participant.invitation_set.first(),
Expand Down Expand Up @@ -1232,7 +1240,13 @@ def send_invitation_button(request, year, banquet_pk, invitation_pk):
)

send_invitation_mail(
request, invitation, name, banquet.date, banquet.location, link, email, fair
request,
invitation,
name,
banquet,
link,
email,
fair,
)

return render(
Expand Down
18 changes: 18 additions & 0 deletions people/migrations/0016_add_show_in_banquet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.24 on 2024-10-02 13:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('people', '0015_remove_dietary_preferences'),
]

operations = [
migrations.AddField(
model_name='dietaryrestriction',
name='show_in_banquet',
field=models.BooleanField(default=True),
),
]
1 change: 1 addition & 0 deletions people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __str__(self):

class DietaryRestriction(models.Model):
name = models.CharField(max_length=255)
show_in_banquet = models.BooleanField(default=True)

class Meta:
ordering = ["name"]
Expand Down
7 changes: 5 additions & 2 deletions templates/banquet/email/invitation.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
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.
Dress code: {{ dress_code }}.
</li>
</ul>
<p 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.
</p>
<p style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left">
See you at the banquet!
</p>
Expand Down
2 changes: 1 addition & 1 deletion templates/banquet/invitation_internal.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ <h1>Thank you!</h1>
</li>
<li>
<span style="font-weight: bold">Dietary restrictions:</span>
{% if invitation.participant.dietary_restrictions.all %}
{% if invitation.participant.dietary_restrictions %}
{{ invitation.participant.dietary_restrictions.all | join:', ' }}
{% else %}
<span style="font-style: italic">none</span>
Expand Down
8 changes: 5 additions & 3 deletions templates/banquet/manage_participants.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ <h1>{{ banquet.name }} – Participants ({{ participants | length }})</h1>
<th>Name</th>
<th>E-mail address</th>
<th>Alcohol?</th>
<th>Seat</th>
<th style="text-align: right;">Options</th>
<th>Preference (Restrictions)</th>
<!-- <th>Seat</th> -->
<th style="text-align: right; width: 0;">Options</th>
</tr>
</thead>

Expand All @@ -43,7 +44,8 @@ <h1>{{ banquet.name }} – Participants ({{ participants | length }})</h1>
</td>
<td><a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a></td>
<td>{% if participant.alcohol %} Yes {% else %} No {% endif %}</td>
<td style="white-space: nowrap;">{% if participant.seat %} {{ participant.seat.table.name }} – {{ participant.seat.name }} {% endif %}</td>
<td>{{ participant.dietary }}</td>
<!-- <td style="white-space: nowrap;">{% if participant.seat %} {{ participant.seat.table.name }} – {{ participant.seat.name }} {% endif %}</td> -->
<td><a href="{% url 'banquet_manage_participant' fair.year banquet.pk participant.pk %}" class="btn btn-sm btn-default">Details</a></td>
</tr>
{% endfor %}
Expand Down

0 comments on commit 1f2f75a

Please sign in to comment.