mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Additional tests for the item list
This commit is contained in:
@@ -921,7 +921,7 @@ class Item(Versionable):
|
|||||||
This method is used to determine whether this Item is currently available
|
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()
|
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 '
|
raise ValueError('Do not call this directly on items which have properties '
|
||||||
'but call this on their ItemVariation objects')
|
'but call this on their ItemVariation objects')
|
||||||
return min([q.availability() for q in self.quotas.all()])
|
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
|
It returns False, if the item is unavailable or the item's price, if it is
|
||||||
available.
|
available.
|
||||||
"""
|
"""
|
||||||
if self.properties.count() > 0:
|
if self.properties.count() > 0: # NOQA
|
||||||
raise ValueError('Do not call this directly on items which have properties '
|
raise ValueError('Do not call this directly on items which have properties '
|
||||||
'but call this on their ItemVariation objects')
|
'but call this on their ItemVariation objects')
|
||||||
from .signals import determine_availability
|
from .signals import determine_availability
|
||||||
|
|||||||
@@ -93,3 +93,30 @@ class ItemDisplayTest(BrowserTest):
|
|||||||
self.driver.find_element_by_css_selector("section:nth-of-type(1)").text)
|
self.driver.find_element_by_css_selector("section:nth-of-type(1)").text)
|
||||||
self.assertNotIn("Black",
|
self.assertNotIn("Black",
|
||||||
self.driver.find_element_by_css_selector("section:nth-of-type(1)").text)
|
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)
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class EventIndex(EventViewMixin, CartDisplayMixin, TemplateView):
|
|||||||
var.cached_availability[1] = min(var.cached_availability[1],
|
var.cached_availability[1] = min(var.cached_availability[1],
|
||||||
self.request.event.max_items_per_order)
|
self.request.event.max_items_per_order)
|
||||||
|
|
||||||
|
items = [item for item in items if len(item.available_variations) > 0]
|
||||||
|
|
||||||
# Regroup those by category
|
# Regroup those by category
|
||||||
context['items_by_category'] = sorted([
|
context['items_by_category'] = sorted([
|
||||||
# a group is a tuple of a category and a list of items
|
# a group is a tuple of a category and a list of items
|
||||||
|
|||||||
Reference in New Issue
Block a user