Add ability for admins to cancel a waitlist entry
authorMagnus Hagander <magnus@hagander.net>
Fri, 20 Oct 2017 08:33:49 +0000 (10:33 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 20 Oct 2017 08:33:49 +0000 (10:33 +0200)
This makes it possible to get people off the waitlist who are not
supposed to be there without having to edit the database directly. Will
also send a notification both to admins and to the attendee in question.

postgresqleu/confreg/views.py
postgresqleu/urls.py
template/confreg/admin_waitlist.html
template/confreg/admin_waitlist_list.inc.html
template/confreg/mail/waitlist_admin_cancel.txt [new file with mode: 0644]

index bda3f309670a6642c366c3f84f158a1a2cf66161..2488c005ead336fba2f2ff4750438c408ab0299a 100644 (file)
@@ -2120,6 +2120,40 @@ def admin_waitlist(request, urlname):
                'form': form,
                }, RequestContext(request))
 
+@login_required
+@transaction.atomic
+def admin_waitlist_cancel(request, urlname, wlid):
+       if request.user.is_superuser:
+               conference = get_object_or_404(Conference, urlname=urlname)
+       else:
+               conference = get_object_or_404(Conference, urlname=urlname, administrators=request.user)
+
+       wl = get_object_or_404(RegistrationWaitlistEntry, pk=wlid, registration__conference=conference)
+       reg = wl.registration
+       wl.delete()
+
+       send_simple_mail(reg.conference.contactaddr,
+                                        reg.conference.contactaddr,
+                                        'Waitlist cancel',
+                                        u'User {0} {1} <{2}> removed from the waitlist by {3}.'.format(reg.firstname, reg.lastname, reg.email, request.user),
+                                        sendername=reg.conference.conferencename)
+
+       send_template_mail(reg.conference.contactaddr,
+                                          reg.email,
+                                          'Waitlist canceled',
+                                          'confreg/mail/waitlist_admin_cancel.txt',
+                                          {
+                                                  'conference': conference,
+                                                  'reg': reg,
+                                          },
+                                          sendername=reg.conference.conferencename,
+                                          receivername=reg.fullname,
+                                          )
+
+       messages.info(request, "Waitlist entry removed.")
+       return HttpResponseRedirect("../../")
+
+
 @login_required
 @transaction.atomic
 def admin_attendeemail(request, urlname):
index 59495806e8aa52a4fd9ca199560ac906c40b1172..44b4639b388fd06c97e86dad8638b3e61fc6793c 100644 (file)
@@ -108,6 +108,7 @@ urlpatterns = patterns('',
     (r'^events/admin/(\w+)/mail/(\d+)/$', postgresqleu.confreg.views.admin_attendeemail_view),
     (r'^events/admin/(\w+)/regdashboard/$', postgresqleu.confreg.views.admin_registration_dashboard),
     (r'^events/admin/(\w+)/waitlist/$', postgresqleu.confreg.views.admin_waitlist),
+    (r'^events/admin/(\w+)/waitlist/cancel/(\d+)/$', postgresqleu.confreg.views.admin_waitlist_cancel),
     (r'^events/admin/(\w+)/wiki/$', postgresqleu.confwiki.views.admin),
     (r'^events/admin/(\w+)/wiki/(new|\d+)/$', postgresqleu.confwiki.views.admin_edit_page),
     (r'^events/admin/(\w+)/signups/$', postgresqleu.confwiki.views.signup_admin),
index 7628f37eb1d66956f9489889f1318af1745be79f..0f185e93f4b6d7050aa891c5afc0fbe65fc247ef 100644 (file)
@@ -20,6 +20,12 @@ function showDialog(id) {
       'title': 'Status history',
    }).dialog('open');
 }
+
+function cancelWaitlist(id) {
+   if (confirm('Are you really sure you want to cancel this waitlist entry?\nAll history will be lost, and a notification sent.')) {
+      document.location.href = 'cancel/' + id + '/';
+   }
+}
 </script>
 {%endblock%}
 
index 36e39578bb3c0f1480911515d9c9477aaa2284f2..ac36a69a55201bbe3d934e6a7548e774344771f4 100644 (file)
@@ -28,7 +28,7 @@
     <td style="white-space: nowrap"><span onClick="showDialog({{w.registration.id}})" class="dlgClickable ui-icon ui-icon-circle-plus" style="display: inline-block"></span>
 {%if w.registration.payconfirmedat%}Registered{%elif w.offeredon%}Offered{%if w.registration.invoice%} (with invoice){%endif%}{%else%}Pending ({{w.offers_made}} offers){%endif%}</td>
 {%if waitlist_type == "waitlist_active" %}
-    {%if not w.offeredon and not w.registration.payconfirmedat%}<td style="white-space: nowrap;"><input type="checkbox" name="reg_{{w.registration.id}}" value="1"{%if w.registration.id in form.reg_list%} CHECKED{%endif%}> offer</td>{%else%}<td></td>{%endif%}
+    {%if not w.offeredon and not w.registration.payconfirmedat%}<td style="white-space: nowrap;"><input type="checkbox" name="reg_{{w.registration.id}}" value="1"{%if w.registration.id in form.reg_list%} CHECKED{%endif%}> offer<br><a href="javascript:cancelWaitlist({{w.pk}})" class="btn btn-default btn-xs">Cancel</a></td>{%else%}<td></td>{%endif%}
 {%endif%}
   </tr>
 {%endfor%}
diff --git a/template/confreg/mail/waitlist_admin_cancel.txt b/template/confreg/mail/waitlist_admin_cancel.txt
new file mode 100644 (file)
index 0000000..6fca571
--- /dev/null
@@ -0,0 +1,10 @@
+Hello!
+
+Your entry on the waitlist for {{conference.conferencename}}
+has been canceled by an administrator.
+
+This probably happened because of some ongoing modification to your
+registration. If you are not already in contact with the conference
+organizers about this, and have any questions about why this is
+done, please contact us as soon as you can by replying to this
+email.