Properly implement quota handling when receiving payments (closes #11)

This commit is contained in:
Raphael Michel
2015-04-14 16:20:05 +02:00
parent 2f7ab1957a
commit df524f31d5
10 changed files with 194 additions and 19 deletions

View File

@@ -31,6 +31,7 @@
{% bootstrap_field form.presale_end layout="horizontal" %}
{% bootstrap_field sform.payment_term_days layout="horizontal" %}
{% bootstrap_field sform.payment_term_last layout="horizontal" %}
{% bootstrap_field sform.payment_term_accept_late layout="horizontal" %}
{% bootstrap_field sform.last_order_modification_date layout="horizontal" %}
</fieldset>
<fieldset>

View File

@@ -61,6 +61,14 @@ class EventSettingsForm(SettingsForm):
"days configured above."),
required=False
)
payment_term_accept_late = forms.BooleanField(
label='Accept late payments',
help_text=_("Accept payments that come after the end of the order's payment term. "
"Payments will only be accepted if the regarding quotas have remaining "
"capacity. No payments will be accepted after the 'Last date of payments' "
"configured above."),
required=False
)
last_order_modification_date = forms.DateTimeField(
label='Last date of modifications',
help_text=_("The last date users can modify details of their orders, such as attendee names or "

View File

@@ -8,7 +8,7 @@ from django.shortcuts import redirect, render
from django.utils.functional import cached_property
from django.views.generic import ListView, DetailView
from pretix.base.models import Order
from pretix.base.models import Order, Quota
from pretix.base.signals import register_payment_providers
from pretix.control.permissions import EventPermissionRequiredMixin
@@ -105,8 +105,12 @@ class OrderTransition(EventPermissionRequiredMixin, OrderView):
def post(self, *args, **kwargs):
to = self.request.POST.get('status', '')
if self.order.status == 'n' and to == 'p':
self.order.mark_paid(manual=True)
messages.success(self.request, _('The order has been marked as paid.'))
try:
self.order.mark_paid(manual=True)
except Quota.QuotaExceededException as e:
messages.error(self.request, str(e))
else:
messages.success(self.request, _('The order has been marked as paid.'))
elif self.order.status == 'n' and to == 'c':
order = self.order.clone()
order.status = Order.STATUS_CANCELLED