mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
Access to consumer object wa buggy
This commit is contained in:
parent
c6603e8aa7
commit
afdc75c0bd
@ -123,24 +123,26 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
|
|||||||
queryset = queryset.order_by("name") \
|
queryset = queryset.order_by("name") \
|
||||||
if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' else queryset
|
if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' else queryset
|
||||||
|
|
||||||
alias = self.request.query_params.get("alias", ".*")
|
alias = self.request.query_params.get("alias", None)
|
||||||
queryset = queryset.prefetch_related('note')
|
queryset = queryset.prefetch_related('note')
|
||||||
# We match first an alias if it is matched without normalization,
|
|
||||||
# then if the normalized pattern matches a normalized alias.
|
if alias:
|
||||||
queryset = queryset.filter(
|
# We match first an alias if it is matched without normalization,
|
||||||
name__iregex="^" + alias
|
# then if the normalized pattern matches a normalized alias.
|
||||||
).union(
|
queryset = queryset.filter(
|
||||||
queryset.filter(
|
name__iregex="^" + alias
|
||||||
Q(normalized_name__iregex="^" + Alias.normalize(alias))
|
).union(
|
||||||
& ~Q(name__iregex="^" + alias)
|
queryset.filter(
|
||||||
),
|
Q(normalized_name__iregex="^" + Alias.normalize(alias))
|
||||||
all=True).union(
|
& ~Q(name__iregex="^" + alias)
|
||||||
queryset.filter(
|
),
|
||||||
Q(normalized_name__iregex="^" + alias.lower())
|
all=True).union(
|
||||||
& ~Q(normalized_name__iregex="^" + Alias.normalize(alias))
|
queryset.filter(
|
||||||
& ~Q(name__iregex="^" + alias)
|
Q(normalized_name__iregex="^" + alias.lower())
|
||||||
),
|
& ~Q(normalized_name__iregex="^" + Alias.normalize(alias))
|
||||||
all=True)
|
& ~Q(name__iregex="^" + alias)
|
||||||
|
),
|
||||||
|
all=True)
|
||||||
|
|
||||||
queryset = queryset if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' \
|
queryset = queryset if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' \
|
||||||
else queryset.order_by("name")
|
else queryset.order_by("name")
|
||||||
|
Loading…
Reference in New Issue
Block a user