fix food facets

This commit is contained in:
smilerz
2021-09-08 17:07:00 -05:00
parent 83a747739a
commit 7b3dee4595

View File

@@ -149,10 +149,13 @@ def search_recipes(request, queryset, params):
if len(search_foods) > 0:
if search_foods_or == 'true':
# TODO creating setting to include descendants of food a setting
queryset = queryset.filter(steps__ingredients__food__id__in=search_foods)
else:
for k in search_foods:
queryset = queryset.filter(steps__ingredients__food__id=k)
# when performing an 'and' search returned recipes should include a parent OR any of its descedants
# AND other foods selected so filters are appended using steps__ingredients__food__id__in the list of foods and descendants
for fd in Food.objects.filter(pk__in=search_foods):
queryset = queryset.filter(steps__ingredients__food__id__in=list(fd.get_descendants_and_self().values_list('pk', flat=True)))
if len(search_books) > 0:
if search_books_or == 'true':