mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
merge ignore shopping with onhand
This commit is contained in:
@@ -75,8 +75,8 @@ def update_food_inheritance(sender, instance=None, created=False, **kwargs):
|
||||
# apply changes from parent to instance for each inheritted field
|
||||
if instance.inherit and instance.parent and inherit.count() > 0:
|
||||
parent = instance.get_parent()
|
||||
if 'ignore_shopping' in inherit:
|
||||
instance.ignore_shopping = parent.ignore_shopping
|
||||
if 'food_onhand' in inherit:
|
||||
instance.food_onhand = parent.food_onhand
|
||||
# if supermarket_category is not set, do not cascade - if this becomes non-intuitive can change
|
||||
if 'supermarket_category' in inherit and parent.supermarket_category:
|
||||
instance.supermarket_category = parent.supermarket_category
|
||||
@@ -89,8 +89,8 @@ def update_food_inheritance(sender, instance=None, created=False, **kwargs):
|
||||
# TODO figure out how to generalize this
|
||||
# apply changes to direct children - depend on save signals for those objects to cascade inheritance down
|
||||
_save = []
|
||||
for child in instance.get_children().filter(inherit=True).exclude(ignore_inherit__field='ignore_shopping'):
|
||||
child.ignore_shopping = instance.ignore_shopping
|
||||
for child in instance.get_children().filter(inherit=True).exclude(ignore_inherit__field='food_onhand'):
|
||||
child.food_onhand = instance.food_onhand
|
||||
_save.append(child)
|
||||
# don't cascade empty supermarket category
|
||||
if instance.supermarket_category:
|
||||
|
||||
Reference in New Issue
Block a user