forked from CGM_Public/pretix_original
OrderChangeManager: Deal with unlimited quotas correctly
This commit is contained in:
@@ -457,7 +457,7 @@ class OrderChangeManager:
|
|||||||
if diff <= 0:
|
if diff <= 0:
|
||||||
continue
|
continue
|
||||||
avail = quota.availability()
|
avail = quota.availability()
|
||||||
if avail[0] != Quota.AVAILABILITY_OK or avail[1] < diff:
|
if avail[0] != Quota.AVAILABILITY_OK or (avail[1] is not None and avail[1] < diff):
|
||||||
raise OrderError(self.error_messages['quota'].format(name=quota.name))
|
raise OrderError(self.error_messages['quota'].format(name=quota.name))
|
||||||
|
|
||||||
def _check_free_to_paid(self):
|
def _check_free_to_paid(self):
|
||||||
|
|||||||
@@ -188,6 +188,14 @@ class OrderChangeManagerTests(TestCase):
|
|||||||
def test_empty(self):
|
def test_empty(self):
|
||||||
self.ocm.commit()
|
self.ocm.commit()
|
||||||
|
|
||||||
|
def test_quota_unlimited(self):
|
||||||
|
q = self.event.quotas.create(name='Test', size=None)
|
||||||
|
q.items.add(self.shirt)
|
||||||
|
self.ocm.change_item(self.op1, self.shirt, None)
|
||||||
|
self.ocm.commit()
|
||||||
|
self.op1.refresh_from_db()
|
||||||
|
assert self.op1.item == self.shirt
|
||||||
|
|
||||||
def test_quota_full(self):
|
def test_quota_full(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