From 591d185b9d5f9f8750a32059ea926ba97cf08e69 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 4 Nov 2020 15:09:35 +0100 Subject: [PATCH] improved random recipe queryset function --- cookbook/views/api.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cookbook/views/api.py b/cookbook/views/api.py index 94c06c5d6a..5937184ae2 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -205,7 +205,8 @@ class RecipeViewSet(viewsets.ModelViewSet, StandardFilterMixin): permission_classes = [CustomIsShare | CustomIsGuest] # TODO split read and write permission for meal plan guest def get_queryset(self): - queryset = Recipe.objects.all() + queryset = self.queryset + internal = self.request.query_params.get('internal', None) if internal: queryset = queryset.filter(internal=True) @@ -213,9 +214,7 @@ def get_queryset(self): if random: queryset = queryset.random(5) - self.queryset = queryset - - return super(RecipeViewSet, self).get_queryset() + return queryset # TODO write extensive tests for permissions