Skip to content

Commit

Permalink
Added waiting list activity cancellation mail being sent.
Browse files Browse the repository at this point in the history
  • Loading branch information
Berehum committed Dec 9, 2024
1 parent 8cba736 commit 736c3a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions amelie/activities/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def activity_send_enrollmentmail(participation, from_waiting_list=False):
translation.activate(current_language)


def activity_send_cancellationmail(participants, activity, request, from_waiting_list=False):
def activity_send_cancellationmail(participations, activity, from_waiting_list=False):
"""
Send a cancellation of enrollment for an activity.
"""
Expand All @@ -88,11 +88,11 @@ def activity_send_cancellationmail(participants, activity, request, from_waiting
template_name = "activities/activity_cancelled_from_waiting_list.mail"

task = MailTask(template_name=template_name)
for participant in participants:
task.add_recipient(PersonRecipient(participant.person, context={
for participation in participations:
task.add_recipient(PersonRecipient(participation.person, context={
'activity': activity,
'participation_costs': participant.calculate_costs()[0],
'paymentmethod': participant.get_payment_method_display()
'participation_costs': participation.calculate_costs()[0],
'paymentmethod': participation.get_payment_method_display()
}))

task.send()
Expand Down
5 changes: 4 additions & 1 deletion amelie/activities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ def activity_cancel(request, pk):
messages.error(_(f'We were unable to cancel {obj}, since it has already started.'))
return redirect(obj)
else:
activity_send_cancellationmail(obj.participation_set.all(), obj, request)
# We need to explicitly set the waiting list to false because they are also included in this set.
activity_send_cancellationmail(obj.participation_set.filter(waiting_list=False), obj)
if obj.waiting_participations.exists():
activity_send_cancellationmail(obj.waiting_participations.all(), obj, from_waiting_list=True)

# Send an email to the treasurer if people have paid in cash.
# This email contains the names and amount paid by each person.
Expand Down

0 comments on commit 736c3a6

Please sign in to comment.