mirror of
https://github.com/pretix/pretix.git
synced 2026-08-29 13:44:40 +00:00
Order change: Allow to ignore quotas
This commit is contained in:
@@ -1306,7 +1306,7 @@ class OrderChangeManager:
|
|||||||
except SendMailException:
|
except SendMailException:
|
||||||
logger.exception('Order changed email could not be sent')
|
logger.exception('Order changed email could not be sent')
|
||||||
|
|
||||||
def commit(self):
|
def commit(self, check_quotas=True):
|
||||||
if self._committed:
|
if self._committed:
|
||||||
# an order change can only be committed once
|
# an order change can only be committed once
|
||||||
raise OrderError(error_messages['internal'])
|
raise OrderError(error_messages['internal'])
|
||||||
@@ -1323,7 +1323,8 @@ class OrderChangeManager:
|
|||||||
with self.order.event.lock():
|
with self.order.event.lock():
|
||||||
if self.order.status not in (Order.STATUS_PENDING, Order.STATUS_PAID):
|
if self.order.status not in (Order.STATUS_PENDING, Order.STATUS_PAID):
|
||||||
raise OrderError(self.error_messages['not_pending_or_paid'])
|
raise OrderError(self.error_messages['not_pending_or_paid'])
|
||||||
self._check_quotas()
|
if check_quotas:
|
||||||
|
self._check_quotas()
|
||||||
self._check_complete_cancel()
|
self._check_complete_cancel()
|
||||||
self._perform_operations()
|
self._perform_operations()
|
||||||
self._recalculate_total_and_payment_fee()
|
self._recalculate_total_and_payment_fee()
|
||||||
|
|||||||
@@ -177,6 +177,10 @@ class OtherOperationsForm(forms.Form):
|
|||||||
'Send an email to the customer notifying that their order has been changed.'
|
'Send an email to the customer notifying that their order has been changed.'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
ignore_quotas = forms.BooleanField(
|
||||||
|
label=_('Allow to overbook quotas when performing this operation'),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.pop('order')
|
kwargs.pop('order')
|
||||||
|
|||||||
@@ -206,6 +206,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="">
|
||||||
|
{% bootstrap_field other_form.ignore_quotas layout="" %}
|
||||||
|
</div>
|
||||||
<div class="form-group submit-group">
|
<div class="form-group submit-group">
|
||||||
<a class="btn btn-default btn-lg"
|
<a class="btn btn-default btn-lg"
|
||||||
href="{% url "control:event.order" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
|
href="{% url "control:event.order" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
|
||||||
|
|||||||
@@ -1259,7 +1259,7 @@ class OrderChange(OrderView):
|
|||||||
messages.error(self.request, _('An error occurred. Please see the details below.'))
|
messages.error(self.request, _('An error occurred. Please see the details below.'))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
ocm.commit()
|
ocm.commit(check_quotas=not self.other_form.cleaned_data['ignore_quotas'])
|
||||||
except OrderError as e:
|
except OrderError as e:
|
||||||
messages.error(self.request, str(e))
|
messages.error(self.request, str(e))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -816,6 +816,14 @@ class OrderChangeManagerTests(TestCase):
|
|||||||
self.op1.refresh_from_db()
|
self.op1.refresh_from_db()
|
||||||
assert self.op1.item == self.ticket
|
assert self.op1.item == self.ticket
|
||||||
|
|
||||||
|
def test_quota_ignore(self):
|
||||||
|
q = self.event.quotas.create(name='Test', size=0)
|
||||||
|
q.items.add(self.shirt)
|
||||||
|
self.ocm.change_item(self.op1, self.shirt, None)
|
||||||
|
self.ocm.commit(check_quotas=False)
|
||||||
|
self.op1.refresh_from_db()
|
||||||
|
assert self.op1.item == self.shirt
|
||||||
|
|
||||||
def test_quota_full_but_in_same(self):
|
def test_quota_full_but_in_same(self):
|
||||||
q = self.event.quotas.create(name='Test', size=0)
|
q = self.event.quotas.create(name='Test', size=0)
|
||||||
q.items.add(self.shirt)
|
q.items.add(self.shirt)
|
||||||
|
|||||||
Reference in New Issue
Block a user