From 293027a1b67a1ad88bdaaa4ebdd2f87157076521 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Mon, 20 Sep 2021 15:54:56 +0200 Subject: [PATCH] fixed sharing with new search system --- cookbook/helper/recipe_search.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cookbook/helper/recipe_search.py b/cookbook/helper/recipe_search.py index 11743b916..85c456394 100644 --- a/cookbook/helper/recipe_search.py +++ b/cookbook/helper/recipe_search.py @@ -9,7 +9,7 @@ from django.db.models import Avg, Case, Count, Func, Max, Q, Subquery, Value, Wh from django.utils import timezone, translation from cookbook.managers import DICTIONARY -from cookbook.models import Food, Keyword, ViewLog +from cookbook.models import Food, Keyword, ViewLog, SearchPreference class Round(Func): @@ -20,7 +20,10 @@ class Round(Func): # TODO create extensive tests to make sure ORs ANDs and various filters, sorting, etc work as expected # TODO consider creating a simpleListRecipe API that only includes minimum of recipe info and minimal filtering def search_recipes(request, queryset, params): - search_prefs = request.user.searchpreference + if request.user.is_authenticated: + search_prefs = request.user.searchpreference + else: + search_prefs = SearchPreference() search_string = params.get('query', '') search_rating = int(params.get('rating', 0)) search_keywords = params.getlist('keywords', [])