Make it possible to remove an unconfirmed registration
authorMagnus Hagander <magnus@hagander.net>
Sat, 17 Nov 2018 18:41:29 +0000 (19:41 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sat, 17 Nov 2018 18:41:29 +0000 (19:41 +0100)
Previously we could only cancel a registration once it was confirmed.
But given the new system to "register for somebody else", it seems to be
more common to have to remove one that has *not* been confirmed,
particularly when it has been created by somebody other than the actual
attendee.

postgresqleu/confreg/models.py
postgresqleu/confreg/util.py
postgresqleu/confreg/views.py
template/confreg/admin_registration_cancel.html
template/confreg/admin_registration_single.html
template/confreg/mail/reg_canceled.txt

index 959fbad742584a2a790b4178ff400faa88666ed7..2057b42481a8a9610c652db8f8eaac6ab61bc3b8 100644 (file)
@@ -491,6 +491,8 @@ class ConferenceRegistration(models.Model):
 
        @property
        def can_edit(self):
+               # Can this registration be edited by the end user (which also implies
+               # it can be deleted)
                return not (self.payconfirmedat or self.invoice or self.bulkpayment)
 
        def short_regtype(self):
index 73409b224e75f203425b0a0a35b98729f0926395..65fe6259c6d11c47e8a13b0379f7ff99f5d79d61 100644 (file)
@@ -144,10 +144,13 @@ def notify_reg_confirmed(reg, updatewaitlist=True):
        )
 
 
-def cancel_registration(reg):
+def cancel_registration(reg, is_unconfirmed=False):
        # Verify that we're only canceling a real registration
        if not reg.payconfirmedat:
-               raise Exception("Registration not paid, data is out of sync!")
+               # If we don't allow canceling an unpaid registration, and the registration
+               # actually is unpaid, then boom.
+               if not is_unconfirmed:
+                       raise Exception("Registration not paid, data is out of sync!")
 
        # If we sent a welcome mail, also send a goodbye mail
        if reg.conference.sendwelcomemail:
@@ -158,6 +161,7 @@ def cancel_registration(reg):
                                                   {
                                                           'conference': reg.conference,
                                                           'reg': reg,
+                                                          'unconfirmed': is_unconfirmed,
                                                   },
                                                   sendername=reg.conference.conferencename,
                                                   receivername=reg.fullname,
index fd05ef3a9987833a12ada53ab2219292758ed261..8f5fcbf61e7546ea8213e9bac82a7b5f0cd360b5 100644 (file)
@@ -2656,7 +2656,8 @@ def admin_registration_cancel(request, urlname, regid):
 
        if request.method == 'POST' and request.POST.get('docancel') == '1':
                name = reg.fullname
-               cancel_registration(reg)
+               is_unconfirmed = (reg.payconfirmedat is None)
+               cancel_registration(reg, is_unconfirmed)
                return render(request, 'confreg/admin_registration_cancel_confirm.html', {
                        'conference': conference,
                        'name': name,
index 17266cfc6a2c24a067a0826001347c3e0ef18813..c8447c0017abaa1961596fd9452e60fc3e2ad70a 100644 (file)
@@ -28,17 +28,22 @@ function confirmit() {
   so you will <i>also</i> need to manually cancel thre reservation in question.
 </p>
 <a class="btn btn-default btn-block" href="/invoiceadmin/{{reg.bulkpayment.invoice.pk}}/refund/">Refund bulk invoice</a>
-{%else%}
+{%elif reg.payconfirmedat%}
 <p>
   This registration does not have an invoice or bulk payment. That means it was either
   a no-pay registration (such as voucher) or a manually confirmed one (speaker, staff,
   or fully manual).
 </p>
+{%else%}
+<p>
+  This registration has not been finalized, and can be removed without refund.
+</p>
 {%endif%}
 <form method="post" action=".">{% csrf_token %}
   <input type="hidden" name="docancel" value="1">
-  <input type="submit" class="btn btn-default btn-block" value="Cancel registration without refund"  onclick="return confirmit()">
+  <input type="submit" class="btn btn-default btn-block" value="{%if payconfirmedat%}Cancel registration without refund{%else%}Remove unconfirmed registration{%endif%}"  onclick="return confirmit()">
 </form>
+<p></p>
 
 <a class="btn btn-default btn-block" href="/events/admin/{{conference.urlname}}/regdashboard/list/{{reg.id}}/">Back to registration</a>
 
index a8fd3e0afeeddd15bceea5ce923c5961a505c8d8..f90681912a49cecd8a5b51303ba6e8b22c9c06a3 100644 (file)
 {%if reg.payconfirmedat%}
 <a class="btn btn-default btn-block" href="/events/admin/{{conference.urlname}}/regdashboard/list/{{reg.id}}/cancel/">Cancel registration</a>
 {%endif%}
-
+{%if reg.can_edit %}
+<a class="btn btn-default btn-block" href="/events/admin/{{conference.urlname}}/regdashboard/list/{{reg.id}}/cancel/">Remove unconfirmed registration entry</a>
+{%endif%}
 <a class="btn btn-default btn-block" href="/events/admin/{{conference.urlname}}/regdashboard/list/">Back to list</a>
 
 {%endblock%}
index eb9c07f8c45202bb4458fb636358639741dad881..ee346cc86105c7886de294e92f13205201f9a356 100644 (file)
@@ -1,9 +1,10 @@
-Your registration for {{conference.conferencename}} has been canceled.
+Your {%if unconfirmed%}unfinished {%endif%}registration for {{conference.conferencename}} has been {%if unconfirmed%}removed{%else%}canceled{%endif%}.
 
 If you did not expect this or do not know why this happened,
 please contact us ASAP by responding to this email, and we will
 investigate the situation.
 
-Your registration has now been fully canceled, so you do not need
+{%if not unconfirmed%}Your registration has now been fully canceled, so you do not need
 to do anything else to complete it. We hope to see you again at
 a future event!
+{%endif%}