Fix after rebase

This commit is contained in:
smilerz
2021-08-24 22:47:13 -05:00
parent 35dc981713
commit 44aa05fe5c
14 changed files with 31 additions and 31 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, Value
from django.db.models import Q
from django.db.models.fields.related import ForeignObjectRel
from django.http import FileResponse, HttpResponse, JsonResponse
from django_scopes import scopes_disabled
@ -114,9 +114,8 @@ class FuzzyFilterMixin(ViewSetMixin):
)
else:
# TODO have this check unaccent search settings or other search preferences?
# 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')
# 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)
updated_at = self.request.query_params.get('updated_at', None)
if updated_at is not None:
@ -212,7 +211,7 @@ class TreeMixin(MergeMixin, FuzzyFilterMixin):
elif tree:
if tree.isnumeric():
try:
self.queryset = self.model.objects.get(id=int(tree)).get_descendants_and_self().filter(space=self.request.space)
self.queryset = self.model.objects.get(id=int(tree)).get_descendants_and_self()
except self.model.DoesNotExist:
self.queryset = self.model.objects.none()
else: