summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2019-03-29 13:33:42 +0000
committerMagnus Hagander2019-03-29 13:33:42 +0000
commit36daa137dd9d75f4f7bccca8cbfcc3d9a4230dd2 (patch)
tree4b8f4410d86c535477dc3fd13409778901dfdb7c
parent84381802b8392e3325a10538e325718d83bb5ae3 (diff)
Make it possible for an end user to cancel a multireg invoice
We already allowed end users to cancel their own personal invoices in case they needed to make any changes to them. With this we also allow it when registering for somebody else, including when this somebody else is multiple people.
-rw-r--r--postgresqleu/confreg/views.py24
-rw-r--r--postgresqleu/urls.py1
-rw-r--r--template.jinja/confreg/invoicecancel.html2
-rw-r--r--template.jinja/confreg/regmulti_bulk.html5
-rw-r--r--template.jinja/confreg/regmulti_cancel.html35
5 files changed, 66 insertions, 1 deletions
diff --git a/postgresqleu/confreg/views.py b/postgresqleu/confreg/views.py
index 373ce318..47b2fa42 100644
--- a/postgresqleu/confreg/views.py
+++ b/postgresqleu/confreg/views.py
@@ -653,6 +653,30 @@ def multireg_bulkview(request, confname, bulkid):
@login_required
@transaction.atomic
+def multireg_bulk_cancel(request, confname, bulkid):
+ conference = get_object_or_404(Conference, urlname=confname)
+ bp = get_object_or_404(BulkPayment, conference=conference, pk=bulkid, user=request.user)
+
+ if not bp.invoice:
+ return HttpResponseRedirect("../")
+ if bp.invoice.paidat or bp.invoice.deleted:
+ return HttpResponseRedirect("../")
+
+ if request.method == 'POST':
+ if request.POST['submit'].find('Cancel invoice') >= 0:
+ manager = InvoiceManager()
+ manager.cancel_invoice(bp.invoice, "User {0} requested cancellation".format(request.user))
+ return HttpResponseRedirect('../../')
+ else:
+ return HttpResponseRedirect('../')
+
+ return render_conference_response(request, conference, 'reg', 'confreg/regmulti_cancel.html', {
+ 'bp': bp,
+ })
+
+
+@login_required
+@transaction.atomic
def multireg_attach(request, token):
reg = get_object_or_404(ConferenceRegistration, regtoken=token)
if reg.attendee:
diff --git a/postgresqleu/urls.py b/postgresqleu/urls.py
index 75dc186e..6536d8dc 100644
--- a/postgresqleu/urls.py
+++ b/postgresqleu/urls.py
@@ -80,6 +80,7 @@ urlpatterns.extend([
url(r'^events/(?P<confname>[^/]+)/register/other/(?P<regid>(\d+)/)?$', postgresqleu.confreg.views.multireg),
url(r'^events/(?P<confname>[^/]+)/register/other/newinvoice/$', postgresqleu.confreg.views.multireg_newinvoice),
url(r'^events/(?P<confname>[^/]+)/register/other/b(?P<bulkid>(\d+))/$', postgresqleu.confreg.views.multireg_bulkview),
+ url(r'^events/(?P<confname>[^/]+)/register/other/b(?P<bulkid>(\d+))/cancel/$', postgresqleu.confreg.views.multireg_bulk_cancel),
url(r'^events/(?P<confname>[^/]+)/register/other/z/$', postgresqleu.confreg.views.multireg_zeropay),
url(r'^events/(?P<confname>[^/]+)/register/change/$', postgresqleu.confreg.views.changereg),
url(r'^events/register/attach/([a-z0-9]{64})/$', postgresqleu.confreg.views.multireg_attach),
diff --git a/template.jinja/confreg/invoicecancel.html b/template.jinja/confreg/invoicecancel.html
index 52739534..67ab18b1 100644
--- a/template.jinja/confreg/invoicecancel.html
+++ b/template.jinja/confreg/invoicecancel.html
@@ -3,7 +3,7 @@
{%block content%}
<h1>Cancel registration invoice</h1>
<p>
-Are you sure that you want to cancel the invoice for this registration? Not that
+Are you sure that you want to cancel the invoice for this registration? Note that
by canceling your invoice, you may lose your seat if the event is full!
</p>
<form method="post" action=".">{{ csrf_input }}
diff --git a/template.jinja/confreg/regmulti_bulk.html b/template.jinja/confreg/regmulti_bulk.html
index 21fa9aca..b8f46a33 100644
--- a/template.jinja/confreg/regmulti_bulk.html
+++ b/template.jinja/confreg/regmulti_bulk.html
@@ -10,6 +10,11 @@ This payment is associated with the following invoice. Note that
since this invoice has been created, there is no longer any way to
modify the contents of it.
</p>
+<p>
+ If you need to make any changes to it, you
+ can <a href="cancel/">cancel</a> the invoice and create a new
+ one.
+</p>
{%endif%}
{%include "invoices/userinvoice_spec.html" %}
diff --git a/template.jinja/confreg/regmulti_cancel.html b/template.jinja/confreg/regmulti_cancel.html
new file mode 100644
index 00000000..6c627fb3
--- /dev/null
+++ b/template.jinja/confreg/regmulti_cancel.html
@@ -0,0 +1,35 @@
+{%extends "base.html" %}
+{%block title%}Cancel multi registration invoice{%endblock%}
+{%block content%}
+<h1>Cancel multi registration invoice</h1>
+<p>
+Are you sure that you want to cancel the invoice for these registrations? Note that
+by canceling your invoice, you may lose your seats if the event is full! Also note
+that all attendees covered by the invoice may receive an email informing them of
+the cancellation (if it is attached to their account).
+</p>
+<form method="post" action=".">{{ csrf_input }}
+<table style="border: 1px solid black;">
+ <tr>
+ <td style="white-space: nowrap">Conference:</td>
+ <td>{{bp.conference}}</td>
+ </tr>
+ <tr>
+ <td style="white-space: nowrap">Attendees:</td>
+ <td>
+ <ul>
+{%for r in bp.conferenceregistration_set.all() %}
+ <li>{{r.fullname}}</li>
+{%endfor%}
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td style="white-space: nowrap">Invoice number:</td>
+ <td>{{bp.invoice}}</td>
+ </tr>
+</table>
+<input type="submit" name="submit" value="Cancel invoice">
+<input type="submit" name="submit" value="Return without canceling">
+</form>
+{%endblock%}