Allow to explicitly disable products for certain subevents

This commit is contained in:
Raphael Michel
2020-06-20 19:10:44 +02:00
parent 0aebde62eb
commit 481e29c3b2
15 changed files with 301 additions and 16 deletions

View File

@@ -477,6 +477,22 @@ class CartTest(CartTestMixin, TestCase):
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
self.assertEqual(len(objs), 0)
def test_subevent_disabled(self):
self.event.has_subevents = True
self.event.save()
with scopes_disabled():
se = self.event.subevents.create(name='Foo', date_from=now(), active=True)
q = se.quotas.create(name="foo", size=None, event=self.event)
q.items.add(self.ticket)
SubEventItem.objects.create(subevent=se, item=self.ticket, price=42, disabled=True)
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
'item_%d' % self.ticket.id: '1',
'subevent': se.pk
}, follow=False)
with scopes_disabled():
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
self.assertEqual(len(objs), 0)
def test_subevent_price(self):
self.event.has_subevents = True
self.event.save()
@@ -613,6 +629,22 @@ class CartTest(CartTestMixin, TestCase):
self.assertEqual(objs[0].variation, self.shirt_red)
self.assertEqual(objs[0].price, 16)
def test_subevent_variation_disabled(self):
self.event.has_subevents = True
self.event.save()
with scopes_disabled():
se = self.event.subevents.create(name='Foo', date_from=now(), active=True)
q = se.quotas.create(name="foo", size=None, event=self.event)
q.variations.add(self.shirt_red)
SubEventItemVariation.objects.create(subevent=se, variation=self.shirt_red, price=42, disabled=True)
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
'variation_%d_%d' % (self.shirt.id, self.shirt_red.id): '1',
'subevent': se.pk
}, follow=False)
with scopes_disabled():
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
self.assertEqual(len(objs), 0)
def test_subevent_variation_price(self):
self.event.has_subevents = True
self.event.save()