get_all_variations: return an empty dict in the list if there are no

properties
This commit is contained in:
Raphael Michel
2014-10-06 14:26:58 +02:00
parent 5e04dd4e9f
commit 495b7a9ce0
2 changed files with 3 additions and 1 deletions

View File

@@ -555,6 +555,7 @@ class Item(models.Model):
result = []
for comb in product(*[prop.values.all() for prop in all_properties]):
if len(comb) == 0:
result.append({})
continue
key = []
var = {}

View File

@@ -33,7 +33,8 @@ class ItemVariationsTest(TestCase):
# No properties available
v = i.get_all_variations()
self.assertEqual(len(v), 0)
self.assertEqual(len(v), 1)
self.assertEqual(v[0], {})
# One property, no variations
p = Property.objects.get(event=e, name='Size')