forked from CGM_Public/pretix_original
Fixed missing check for variation.active
This commit is contained in:
@@ -140,7 +140,7 @@ def _add_new_items(event: Event, items: List[dict],
|
|||||||
if item.hide_without_voucher and (voucher is None or voucher.item is None or voucher.item.pk != item.pk):
|
if item.hide_without_voucher and (voucher is None or voucher.item is None or voucher.item.pk != item.pk):
|
||||||
return error_messages['voucher_required']
|
return error_messages['voucher_required']
|
||||||
|
|
||||||
if len(quotas) == 0 or not item.is_available():
|
if len(quotas) == 0 or not item.is_available() or (variation and not variation.active):
|
||||||
err = err or error_messages['unavailable']
|
err = err or error_messages['unavailable']
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ def _check_positions(event: Event, now_dt: datetime, positions: List[CartPositio
|
|||||||
|
|
||||||
voucherids = set()
|
voucherids = set()
|
||||||
for i, cp in enumerate(positions):
|
for i, cp in enumerate(positions):
|
||||||
if not cp.item.active:
|
if not cp.item.active or (cp.variation and not cp.variation.active):
|
||||||
err = err or error_messages['unavailable']
|
err = err or error_messages['unavailable']
|
||||||
cp.delete()
|
cp.delete()
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -117,6 +117,17 @@ class CartTest(CartTestMixin, TestCase):
|
|||||||
self.assertIsNone(objs[0].variation)
|
self.assertIsNone(objs[0].variation)
|
||||||
self.assertEqual(objs[0].price, 23)
|
self.assertEqual(objs[0].price, 23)
|
||||||
|
|
||||||
|
def test_variation_inactive(self):
|
||||||
|
self.shirt_red.active = False
|
||||||
|
self.shirt_red.save()
|
||||||
|
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||||
|
'variation_%d_%d' % (self.shirt.id, self.shirt_red.id): '1'
|
||||||
|
}, follow=True)
|
||||||
|
self.assertRedirects(response, '/%s/%s/' % (self.orga.slug, self.event.slug),
|
||||||
|
target_status_code=200)
|
||||||
|
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
|
||||||
|
self.assertEqual(len(objs), 0)
|
||||||
|
|
||||||
def test_variation(self):
|
def test_variation(self):
|
||||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||||
'variation_%d_%d' % (self.shirt.id, self.shirt_red.id): '1'
|
'variation_%d_%d' % (self.shirt.id, self.shirt_red.id): '1'
|
||||||
|
|||||||
Reference in New Issue
Block a user