moved food and keyword to generic cards

This commit is contained in:
smilerz
2021-08-19 12:36:39 -05:00
parent aba2e66163
commit d606ea8db3
19 changed files with 377 additions and 138793 deletions

View File

@ -12,7 +12,7 @@ from django.contrib.auth.models import User
from django.contrib.postgres.search import TrigramSimilarity
from django.core.exceptions import FieldError, ValidationError
from django.core.files import File
from django.db.models import Q
from django.db.models import Q, Value
from django.db.models.fields.related import ForeignObjectRel
from django.http import FileResponse, HttpResponse, JsonResponse
from django_scopes import scopes_disabled
@ -114,8 +114,9 @@ class FuzzyFilterMixin(ViewSetMixin):
)
else:
# TODO have this check unaccent search settings or other search preferences?
# TODO for some querysets exact matches are sorted beyond pagesize, need to find better solution
self.queryset = self.queryset.filter(name__istartswith=query) | self.queryset.filter(name__icontains=query)
# for some querysets exact matches are sorted beyond pagesize, this ensures exact matches appear first
self.queryset = self.queryset.filter(name__istartswith=query).annotate(order=Value(0)) | self.queryset.filter(name__icontains=query).annotate(order=Value(1))
self.queryset = self.queryset.order_by('order')
updated_at = self.request.query_params.get('updated_at', None)
if updated_at is not None: