mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
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:
@@ -43,6 +43,7 @@ TEST_VOUCHER_RES = {
|
||||
'quota': None,
|
||||
'tag': 'Foo',
|
||||
'comment': '',
|
||||
'show_hidden_items': True,
|
||||
'subevent': None
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user