Commit 1ca9ca2a authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Send email to people on event waiting list

parent ab789961
This diff was suppressed by a .gitattributes entry.
{% load i18n baseurl %}{% blocktrans with event_title=event.title event_url=event.get_absolute_url|date:"SHORT_DATETIME_FORMAT" cancel_deadline=event.cancel_deadline|date:"SHORT_DATETIME_FORMAT" name=member.user.first_name %}Hi {{ name }},
You registered for the event '{{ event_title }}' on {{ registration_date }} and unfortunately you were placed on the waiting list.
However someone just unregistered and we would like to let you know that you'll be able to attend now!
You can find more information about the event on the website: {{ event_url }}
We're assuming that you'll be there, but you're still able to unregister until {{ cancel_deadline }}.
Best regards,
Study Association Thalia{% endblocktrans %}
......@@ -59,7 +59,7 @@
<i>({{ event.max_participants }} {% trans "max" %})</i>
{% with prc=registration_percentage %}
<div class="progress progress-style1">
<div class="bar trans-enabled" style="width: {{ prc }}%;" data-width="{{ prc }}%"></div>
<div class="bar trans-enabled" style="width: {{ prc|floatformat:"0" }}%;" data-width="{{ prc|floatformat:"0" }}%"></div>
{% endwith %}
{% endif %}
......@@ -5,9 +5,12 @@ from datetime import timedelta
from django.contrib import messages
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required, permission_required
from django.core.mail import EmailMessage
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
from django.template import Context
from django.template.loader import get_template
from django.utils import timezone, translation
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import pgettext_lazy
......@@ -192,6 +195,7 @@ def registration(request, event_id, action=None):
success_message = None
error_message = None
show_fields = False
waiting_list_notification = None
if action == 'register' and (
event.status == Event.REGISTRATION_OPEN or
......@@ -225,6 +229,29 @@ def registration(request, event_id, action=None):
elif action == 'cancel':
if (obj is not None and
obj.date_cancelled is None):
# Prepare email to send to the first person on the waiting list
first_waiting = (Registration.objects
.filter(event=event, date_cancelled=None)
first_waiting_member = first_waiting.member
text_template = get_template('events/email.txt')
with translation.override(first_waiting_member.language):
subject = _("[THALIA] Notification about your "
"registration for '{}'").format(event.title)
text_message = text_template.render(Context({
'event': event,
'registration': first_waiting,
'member': first_waiting_member
waiting_list_notification = EmailMessage(
# Note that this doesn't remove the values for the
# information fields that the user entered upon registering.
# But this is regarded as a feature, not a bug. Especially
......@@ -258,4 +285,7 @@ def registration(request, event_id, action=None):
messages.error(request, error_message)
if waiting_list_notification is not None:
return redirect(event)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment