temporary fix to merge ingredients without recipes
This commit is contained in:
parent
b1db591e9f
commit
ed313cbf9a
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.db.models import Q
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
@ -287,7 +288,8 @@ def edit_ingredients(request):
|
|||||||
new_unit = units_form.cleaned_data['new_unit']
|
new_unit = units_form.cleaned_data['new_unit']
|
||||||
old_unit = units_form.cleaned_data['old_unit']
|
old_unit = units_form.cleaned_data['old_unit']
|
||||||
if new_unit != old_unit:
|
if new_unit != old_unit:
|
||||||
recipe_ingredients = Ingredient.objects.filter(unit=old_unit, step__recipe__space=request.space).all()
|
with scopes_disabled():
|
||||||
|
recipe_ingredients = Ingredient.objects.filter(unit=old_unit).filter(Q(step__recipe__space=request.space) | Q(step__recipe__isnull=True)).all()
|
||||||
for i in recipe_ingredients:
|
for i in recipe_ingredients:
|
||||||
i.unit = new_unit
|
i.unit = new_unit
|
||||||
i.save()
|
i.save()
|
||||||
@ -303,7 +305,7 @@ def edit_ingredients(request):
|
|||||||
new_food = food_form.cleaned_data['new_food']
|
new_food = food_form.cleaned_data['new_food']
|
||||||
old_food = food_form.cleaned_data['old_food']
|
old_food = food_form.cleaned_data['old_food']
|
||||||
if new_food != old_food:
|
if new_food != old_food:
|
||||||
ingredients = Ingredient.objects.filter(food=old_food, step__recipe__space=request.space).all()
|
ingredients = Ingredient.objects.filter(food=old_food).filter(Q(step__recipe__space=request.space) | Q(step__recipe__isnull=True)).all()
|
||||||
for i in ingredients:
|
for i in ingredients:
|
||||||
i.food = new_food
|
i.food = new_food
|
||||||
i.save()
|
i.save()
|
||||||
|
Loading…
Reference in New Issue
Block a user