Allow quota-level vouchers for hidden products (#1123)

* Changes in checks

* Backwards-compatible implementation

* Add test

* Fix voucher bulk form
This commit is contained in:
Raphael Michel
2019-07-07 13:36:04 +02:00
committed by GitHub
parent 5180b5e48b
commit ca1c387a41
13 changed files with 69 additions and 14 deletions

View File

@@ -43,6 +43,7 @@ TEST_VOUCHER_RES = {
'quota': None,
'tag': 'Foo',
'comment': '',
'show_hidden_items': True,
'subevent': None
}

View File

@@ -1529,6 +1529,19 @@ class CartTest(CartTestMixin, TestCase):
self.assertEqual(objs[0].item, self.shirt)
self.assertEqual(objs[0].variation, self.shirt_red)
def test_hide_without_voucher_failed_because_of_voucher(self):
with scopes_disabled():
v = Voucher.objects.create(item=self.shirt, event=self.event, show_hidden_items=False)
self.shirt.hide_without_voucher = True
self.shirt.save()
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
'variation_%d_%d' % (self.shirt.id, self.shirt_red.id): '1',
'_voucher_code': v.code
}, follow=True)
with scopes_disabled():
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
self.assertEqual(len(objs), 0)
def test_hide_without_voucher_failed(self):
self.shirt.hide_without_voucher = True
self.shirt.save()

View File

@@ -435,6 +435,14 @@ class VoucherRedeemItemDisplayTest(EventTestMixin, SoupTest):
assert "Early-bird" in html.rendered_content
def test_hide_wo_voucher_quota(self):
self.item.hide_without_voucher = True
self.item.save()
html = self.client.get('/%s/%s/redeem?voucher=%s' % (self.orga.slug, self.event.slug, self.v.code))
assert "Early-bird" in html.rendered_content
def test_hide_wo_voucher_quota_dont_show(self):
self.v.show_hidden_items = False
self.v.save()
self.item.hide_without_voucher = True
self.item.save()
html = self.client.get('/%s/%s/redeem?voucher=%s' % (self.orga.slug, self.event.slug, self.v.code))