From d555207b3132240bd9276c3592c61a9b3ac10c92 Mon Sep 17 00:00:00 2001
From: Magnus Hagander
Date: Sat, 17 Nov 2018 19:41:29 +0100
Subject: [PATCH] Make it possible to remove an unconfirmed registration
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 | 2 ++
postgresqleu/confreg/util.py | 8 ++++++--
postgresqleu/confreg/views.py | 3 ++-
template/confreg/admin_registration_cancel.html | 9 +++++++--
template/confreg/admin_registration_single.html | 4 +++-
template/confreg/mail/reg_canceled.txt | 5 +++--
6 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/postgresqleu/confreg/models.py b/postgresqleu/confreg/models.py
index 959fbad..2057b42 100644
--- a/postgresqleu/confreg/models.py
+++ b/postgresqleu/confreg/models.py
@@ -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):
diff --git a/postgresqleu/confreg/util.py b/postgresqleu/confreg/util.py
index 73409b2..65fe625 100644
--- a/postgresqleu/confreg/util.py
+++ b/postgresqleu/confreg/util.py
@@ -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,
diff --git a/postgresqleu/confreg/views.py b/postgresqleu/confreg/views.py
index fd05ef3..8f5fcbf 100644
--- a/postgresqleu/confreg/views.py
+++ b/postgresqleu/confreg/views.py
@@ -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,
diff --git a/template/confreg/admin_registration_cancel.html b/template/confreg/admin_registration_cancel.html
index 17266cf..c8447c0 100644
--- a/template/confreg/admin_registration_cancel.html
+++ b/template/confreg/admin_registration_cancel.html
@@ -28,17 +28,22 @@ function confirmit() {
so you will also need to manually cancel thre reservation in question.
Refund bulk invoice
-{%else%}
+{%elif reg.payconfirmedat%}
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).
+{%else%}
+
+ This registration has not been finalized, and can be removed without refund.
+
{%endif%}
+
Back to registration
diff --git a/template/confreg/admin_registration_single.html b/template/confreg/admin_registration_single.html
index a8fd3e0..f906819 100644
--- a/template/confreg/admin_registration_single.html
+++ b/template/confreg/admin_registration_single.html
@@ -154,7 +154,9 @@
{%if reg.payconfirmedat%}
Cancel registration
{%endif%}
-
+{%if reg.can_edit %}
+Remove unconfirmed registration entry
+{%endif%}
Back to list
{%endblock%}
diff --git a/template/confreg/mail/reg_canceled.txt b/template/confreg/mail/reg_canceled.txt
index eb9c07f..ee346cc 100644
--- a/template/confreg/mail/reg_canceled.txt
+++ b/template/confreg/mail/reg_canceled.txt
@@ -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%}
--
2.39.5