diff --git a/src/pretix/base/models.py b/src/pretix/base/models.py index 6578eb3afc..bf117a574e 100644 --- a/src/pretix/base/models.py +++ b/src/pretix/base/models.py @@ -921,7 +921,7 @@ class Item(Versionable): This method is used to determine whether this Item is currently available for sale. It may return any of the return codes of Quota.availability() """ - if self.properties.count() > 0: + if self.properties.count() > 0: # NOQA raise ValueError('Do not call this directly on items which have properties ' 'but call this on their ItemVariation objects') return min([q.availability() for q in self.quotas.all()]) @@ -933,7 +933,7 @@ class Item(Versionable): It returns False, if the item is unavailable or the item's price, if it is available. """ - if self.properties.count() > 0: + if self.properties.count() > 0: # NOQA raise ValueError('Do not call this directly on items which have properties ' 'but call this on their ItemVariation objects') from .signals import determine_availability diff --git a/src/pretix/presale/tests/test_event.py b/src/pretix/presale/tests/test_event.py index a52be8b990..ad84a732be 100644 --- a/src/pretix/presale/tests/test_event.py +++ b/src/pretix/presale/tests/test_event.py @@ -93,3 +93,30 @@ class ItemDisplayTest(BrowserTest): self.driver.find_element_by_css_selector("section:nth-of-type(1)").text) self.assertNotIn("Black", self.driver.find_element_by_css_selector("section:nth-of-type(1)").text) + + def test_variation_prices_in_quota(self): + c = ItemCategory.objects.create(event=self.event, name="Entry tickets", position=0) + q = Quota.objects.create(event=self.event, name='Quota', size=2) + item = Item.objects.create(event=self.event, name='Early-bird ticket', category=c, default_price=12) + prop1 = Property.objects.create(event=self.event, name="Color") + item.properties.add(prop1) + val1 = PropertyValue.objects.create(prop=prop1, value="Red", position=0) + val2 = PropertyValue.objects.create(prop=prop1, value="Black", position=1) + q.items.add(item) + var1 = ItemVariation.objects.create(item=item, default_price=14) + var1.values.add(val1) + var2 = ItemVariation.objects.create(item=item) + var2.values.add(val2) + q.variations.add(var1) + q.variations.add(var2) + self.driver.get('%s/%s/%s/' % (self.live_server_url, self.orga.slug, self.event.slug)) + self.assertIn("Early-bird", + self.driver.find_element_by_css_selector("section:nth-of-type(1) div:nth-of-type(1)").text) + self.assertIn("Red", + self.driver.find_elements_by_css_selector("section:nth-of-type(1) div.variation")[0].text) + self.assertIn("14.00", + self.driver.find_elements_by_css_selector("section:nth-of-type(1) div.variation")[0].text) + self.assertIn("Black", + self.driver.find_elements_by_css_selector("section:nth-of-type(1) div.variation")[1].text) + self.assertIn("12.00", + self.driver.find_elements_by_css_selector("section:nth-of-type(1) div.variation")[1].text) diff --git a/src/pretix/presale/views/event.py b/src/pretix/presale/views/event.py index 7dabb8455c..ad27dc3553 100644 --- a/src/pretix/presale/views/event.py +++ b/src/pretix/presale/views/event.py @@ -46,6 +46,8 @@ class EventIndex(EventViewMixin, CartDisplayMixin, TemplateView): var.cached_availability[1] = min(var.cached_availability[1], self.request.event.max_items_per_order) + items = [item for item in items if len(item.available_variations) > 0] + # Regroup those by category context['items_by_category'] = sorted([ # a group is a tuple of a category and a list of items