From 22968495fd8c55931ea26a75ff413060de53b021 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 25 Feb 2024 17:10:40 +0100 Subject: [PATCH] playing with search --- cookbook/views/api.py | 9 ++++++++ vue3/src/components/display/RecipeView.vue | 10 ++++++-- vue3/src/openapi/apis/ApiApi.ts | 26 +++++++++++++++++++++ vue3/src/pages/RecipeSearchPage.vue | 27 ++++++++++++++++++++-- 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/cookbook/views/api.py b/cookbook/views/api.py index a0ceada12..3d3de5e16 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -1065,6 +1065,15 @@ class RecipeViewSet(viewsets.ModelViewSet): qs = obj.get_related_recipes(levels=levels) # TODO: make levels a user setting, included in request data?, keep solely in the backend? return Response(self.serializer_class(qs, many=True).data) + @decorators.action( + detail=False, + methods=['GET'], + ) + def flat(self, request): + return JsonResponse({'data': list(Recipe.objects.filter(space=request.space).filter( + Q(private=False) | (Q(private=True) & (Q(created_by=self.request.user) | Q(shared=self.request.user))) + ).values_list('name', flat=True))}) + class UnitConversionViewSet(viewsets.ModelViewSet): queryset = UnitConversion.objects diff --git a/vue3/src/components/display/RecipeView.vue b/vue3/src/components/display/RecipeView.vue index 79ca58b98..0e42f0ad8 100644 --- a/vue3/src/components/display/RecipeView.vue +++ b/vue3/src/components/display/RecipeView.vue @@ -72,7 +72,7 @@