mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
WIP
This commit is contained in:
@@ -79,8 +79,7 @@ def is_object_shared(user, obj):
|
||||
# share checks for relevant objects
|
||||
if not user.is_authenticated:
|
||||
return False
|
||||
else:
|
||||
return user in obj.get_shared()
|
||||
return user in obj.get_shared()
|
||||
|
||||
|
||||
def share_link_valid(recipe, share):
|
||||
|
||||
@@ -62,7 +62,7 @@ class ExtendedRecipeMixin(serializers.ModelSerializer):
|
||||
# probably not a tree
|
||||
pass
|
||||
if recipes.count() != 0:
|
||||
return recipes.order_by('?')[:1][0].image.url
|
||||
return random.choice(recipes).image.url
|
||||
else:
|
||||
return None
|
||||
|
||||
@@ -96,7 +96,7 @@ class CustomDecimalField(serializers.Field):
|
||||
class SpaceFilterSerializer(serializers.ListSerializer):
|
||||
|
||||
def to_representation(self, data):
|
||||
if (type(data) == QuerySet and data.query.is_sliced):
|
||||
if (type(data) == QuerySet and data.query.is_sliced) or not self.context.get('request', None):
|
||||
# if query is sliced it came from api request not nested serializer
|
||||
return super().to_representation(data)
|
||||
if self.child.Meta.model == User:
|
||||
|
||||
@@ -675,7 +675,6 @@ class RecipeViewSet(viewsets.ModelViewSet):
|
||||
return Response(self.serializer_class(qs, many=True).data)
|
||||
|
||||
|
||||
# TODO deprecate
|
||||
class ShoppingListRecipeViewSet(viewsets.ModelViewSet):
|
||||
queryset = ShoppingListRecipe.objects
|
||||
serializer_class = ShoppingListRecipeSerializer
|
||||
|
||||
Reference in New Issue
Block a user