From 6135a6f26d37214d80fec1270cf356435db9daeb Mon Sep 17 00:00:00 2001 From: smilerz Date: Thu, 28 Oct 2021 12:05:29 -0500 Subject: [PATCH] fix apis --- cookbook/models.py | 2 +- cookbook/serializer.py | 2 +- cookbook/tests/conftest.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cookbook/models.py b/cookbook/models.py index 44a1f414a..198185975 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -826,7 +826,7 @@ class ShoppingListRecipe(ExportModelOperationsMixin('shopping_list_recipe'), mod def get_owner(self): try: - return self.entries.first().created_by or self.shoppinglist_set.first().created_by + return getattr(self.entries.first(), 'created_by', None) or getattr(self.shoppinglist_set.first(), 'created_by', None) except AttributeError: return None diff --git a/cookbook/serializer.py b/cookbook/serializer.py index b2b6a22b0..d8ad1464b 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -357,7 +357,7 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer, ExtendedR supermarket_category = SupermarketCategorySerializer(allow_null=True, required=False) recipe = RecipeSimpleSerializer(allow_null=True, required=False) shopping = serializers.SerializerMethodField('get_shopping_status') - ignore_inherit = FoodInheritFieldSerializer(many=True) + ignore_inherit = FoodInheritFieldSerializer(many=True, allow_null=True, required=False) recipe_filter = 'steps__ingredients__food' diff --git a/cookbook/tests/conftest.py b/cookbook/tests/conftest.py index 23f71e1a1..7b9b945cc 100644 --- a/cookbook/tests/conftest.py +++ b/cookbook/tests/conftest.py @@ -43,7 +43,7 @@ def space_2(): def get_random_recipe(space_1, u1_s1): r = Recipe.objects.create( - name=uuid.uuid4(), + name=str(uuid.uuid4()), waiting_time=20, working_time=20, servings=4,