diff --git a/src/pretix/presale/productlist.py b/src/pretix/presale/productlist.py index 86fad53f86..f34ee01d8e 100644 --- a/src/pretix/presale/productlist.py +++ b/src/pretix/presale/productlist.py @@ -247,14 +247,15 @@ def prepare_item_list_for_shop(event, *, channel: SalesChannel, subevent=None, v continue if item.hidden_if_item_available: + time_available = item.hidden_if_item_available.is_available() if item.hidden_if_item_available.has_variations: item._dependency_available = any( var.check_quotas(subevent=subevent, _cache=quota_cache, include_bundled=True)[0] == Quota.AVAILABILITY_OK + # is_available on variant is evaluated called by available_variations for var in item.hidden_if_item_available.available_variations - ) + ) and time_available else: q = item.hidden_if_item_available.check_quotas(subevent=subevent, _cache=quota_cache, include_bundled=True) - time_available = item.hidden_if_item_available.is_available() item._dependency_available = (q[0] == Quota.AVAILABILITY_OK) and time_available if item._dependency_available and item.hidden_if_item_available_mode == Item.UNAVAIL_MODE_HIDDEN: item._remove = True diff --git a/src/tests/presale/test_event.py b/src/tests/presale/test_event.py index 053a5eff49..25e405ed6e 100644 --- a/src/tests/presale/test_event.py +++ b/src/tests/presale/test_event.py @@ -744,6 +744,35 @@ class ItemDisplayTest(EventTestMixin, SoupTest): self.assertNotIn("SOLD OUT", doc.select("section:nth-of-type(1)")[0].text) self.assertIn("Late-bird", doc.select("section:nth-of-type(1)")[0].text) + def test_hidden_if_item_available_variation_unavailable_by_time(self): + with scopes_disabled(): + q = Quota.objects.create(event=self.event, name='Early-bird', size=10) + q2 = Quota.objects.create(event=self.event, name='Late-bird', size=10) + item_with_vars = Item.objects.create(event=self.event, name='Early-bird ticket', default_price=12) + v = item_with_vars.variations.create( + value='Regular', active=True, + ) + item2 = Item.objects.create(event=self.event, name='Late-bird ticket', default_price=12, + hidden_if_item_available=item_with_vars) + q.items.add(item_with_vars) + q.variations.add(v) + q2.items.add(item2) + + self.event.settings.hide_sold_out = True + doc = self.get_doc('/%s/%s/' % (self.orga.slug, self.event.slug)) + self.assertIn("Early-bird", doc.select("section:nth-of-type(1)")[0].text) + self.assertNotIn("SOLD OUT", doc.select("section:nth-of-type(1)")[0].text) + self.assertNotIn("Late-bird", doc.select("section:nth-of-type(1)")[0].text) + + item_with_vars.available_until = now() - datetime.timedelta(days=3) + item_with_vars.available_until_mode = "hide" + item_with_vars.save() + + doc = self.get_doc('/%s/%s/' % (self.orga.slug, self.event.slug)) + self.assertNotIn("Early-bird", doc.select("section:nth-of-type(1)")[0].text) + self.assertNotIn("SOLD OUT", doc.select("section:nth-of-type(1)")[0].text) + self.assertIn("Late-bird", doc.select("section:nth-of-type(1)")[0].text) + def test_bundle_sold_out(self): with scopes_disabled(): q = Quota.objects.create(event=self.event, name='Quota', size=2)