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
1 changed files with 4 additions and 1 deletions

View File

@ -106,7 +106,10 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
queryset = super().get_queryset() queryset = super().get_queryset()
alias = self.request.query_params.get("alias", ".*") 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') .order_by('name').prefetch_related('note')
return queryset return queryset