fixed onhand test (cache) and fixed shared recipe properties

This commit is contained in:
vabene1111
2023-05-26 10:57:08 +02:00
parent 3302dacdc3
commit 43105ddd2f
2 changed files with 14 additions and 17 deletions

View File

@ -109,8 +109,7 @@ class CustomOnHandField(serializers.Field):
if not self.context["request"].user.is_authenticated:
return []
shared_users = []
if c := caches['default'].get(
f'shopping_shared_users_{self.context["request"].space.id}_{self.context["request"].user.id}', None):
if c := caches['default'].get(f'shopping_shared_users_{self.context["request"].space.id}_{self.context["request"].user.id}', None):
shared_users = c
else:
try:
@ -845,7 +844,7 @@ class RecipeSerializer(RecipeBaseSerializer):
food_properties = serializers.SerializerMethodField('get_food_properties')
def get_food_properties(self, obj):
fph = FoodPropertyHelper(self.context['request'].space)
fph = FoodPropertyHelper(obj.space) # initialize with object space since recipes might be viewed anonymously
return fph.calculate_recipe_properties(obj)
class Meta: