1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-22 15:32:22 +00:00

Better alias research, closes #51

This commit is contained in:
Yohann D'ANELLO 2020-07-31 17:07:14 +02:00
parent fd705adb05
commit 9008baad3a

View File

@ -106,7 +106,10 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
queryset = super().get_queryset()
alias = self.request.query_params.get("alias", ".*")
queryset = queryset.filter(normalized_name__iregex="^" + Alias.normalize(alias))\
queryset = queryset.filter(
Q(name__regex="^" + alias)
| Q(normalized_name__regex="^" + Alias.normalize(alias))
| Q(normalized_name__regex="^" + alias.lower()))\
.order_by('name').prefetch_related('note')
return queryset