From 89e58edcade32a5d292f523643badf20cef60cc3 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 19 Nov 2025 21:30:20 +0100 Subject: [PATCH] fixed SLR's without entries --- cookbook/helper/shopping_helper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cookbook/helper/shopping_helper.py b/cookbook/helper/shopping_helper.py index f41af4fb9..c2e3d5458 100644 --- a/cookbook/helper/shopping_helper.py +++ b/cookbook/helper/shopping_helper.py @@ -75,7 +75,8 @@ class RecipeShoppingEditor(): @staticmethod def get_shopping_list_recipe(id, user, space): - return ShoppingListRecipe.objects.filter(id=id).filter(entries__space=space).filter( + # TODO this sucks since it wont find SLR's that no longer have any entries + return ShoppingListRecipe.objects.filter(id=id, space=space).filter( Q(entries__created_by=user) | Q(entries__created_by__in=list(user.get_shopping_share())) ).prefetch_related('entries').first() @@ -136,7 +137,8 @@ class RecipeShoppingEditor(): self.servings = servings self._delete_ingredients(ingredients=ingredients) - if self.servings != self._shopping_list_recipe.servings: + # need to check if there is a SLR because its possible it cant be found if all entries are deleted + if self._shopping_list_recipe and self.servings != self._shopping_list_recipe.servings: self.edit_servings() self._add_ingredients(ingredients=ingredients) return True