Refs #105 -- Check quota before blocking it with a voucher

This commit is contained in:
Raphael Michel
2016-08-05 10:18:24 +02:00
parent 58e706b721
commit ce6e8d0f5c
2 changed files with 26 additions and 4 deletions

View File

@@ -172,6 +172,11 @@ class VoucherCreate(EventPermissionRequiredMixin, CreateView):
form.instance.log_action('pretix.voucher.added', data=dict(form.cleaned_data), user=self.request.user)
return ret
def post(self, request, *args, **kwargs):
# TODO: Transform this into an asynchronous call?
with request.event.lock():
return super().post(request, *args, **kwargs)
class VoucherBulkCreate(EventPermissionRequiredMixin, CreateView):
model = Voucher
@@ -208,3 +213,8 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, CreateView):
ctx = super().get_context_data(**kwargs)
ctx['code_length'] = settings.ENTROPY['voucher_code']
return ctx
def post(self, request, *args, **kwargs):
# TODO: Transform this into an asynchronous call?
with request.event.lock():
return super().post(request, *args, **kwargs)