fixed property helper bug with non food ingredients
This commit is contained in:
parent
cadf14c338
commit
a65e93a9b3
@ -39,23 +39,24 @@ class FoodPropertyHelper:
|
|||||||
uch = UnitConversionHelper(self.space)
|
uch = UnitConversionHelper(self.space)
|
||||||
|
|
||||||
for i in ingredients:
|
for i in ingredients:
|
||||||
conversions = uch.get_conversions(i)
|
if i.food is not None:
|
||||||
for pt in property_types:
|
conversions = uch.get_conversions(i)
|
||||||
found_property = False
|
for pt in property_types:
|
||||||
if i.food.properties_food_amount == 0 or i.food.properties_food_unit is None:
|
found_property = False
|
||||||
computed_properties[pt.id]['missing_value'] = True
|
if i.food.properties_food_amount == 0 or i.food.properties_food_unit is None:
|
||||||
computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': i.food.name, 'value': 0}
|
computed_properties[pt.id]['missing_value'] = True
|
||||||
else:
|
computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': i.food.name, 'value': 0}
|
||||||
for p in i.food.properties.all():
|
else:
|
||||||
if p.property_type == pt:
|
for p in i.food.properties.all():
|
||||||
for c in conversions:
|
if p.property_type == pt:
|
||||||
if c.unit == i.food.properties_food_unit:
|
for c in conversions:
|
||||||
found_property = True
|
if c.unit == i.food.properties_food_unit:
|
||||||
computed_properties[pt.id]['total_value'] += (c.amount / i.food.properties_food_amount) * p.property_amount
|
found_property = True
|
||||||
computed_properties[pt.id]['food_values'] = self.add_or_create(computed_properties[p.property_type.id]['food_values'], c.food.id, (c.amount / i.food.properties_food_amount) * p.property_amount, c.food)
|
computed_properties[pt.id]['total_value'] += (c.amount / i.food.properties_food_amount) * p.property_amount
|
||||||
if not found_property:
|
computed_properties[pt.id]['food_values'] = self.add_or_create(computed_properties[p.property_type.id]['food_values'], c.food.id, (c.amount / i.food.properties_food_amount) * p.property_amount, c.food)
|
||||||
computed_properties[pt.id]['missing_value'] = True
|
if not found_property:
|
||||||
computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': i.food.name, 'value': 0}
|
computed_properties[pt.id]['missing_value'] = True
|
||||||
|
computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': i.food.name, 'value': 0}
|
||||||
|
|
||||||
return computed_properties
|
return computed_properties
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user