mirror of https://gitlab.crans.org/bde/nk20
Fix the Alias Search API
This commit is contained in:
parent
b7a71d911d
commit
feeb99041f
|
@ -179,19 +179,10 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
|
||||||
# We match first an alias if it is matched without normalization,
|
# We match first an alias if it is matched without normalization,
|
||||||
# then if the normalized pattern matches a normalized alias.
|
# then if the normalized pattern matches a normalized alias.
|
||||||
queryset = queryset.filter(
|
queryset = queryset.filter(
|
||||||
**{f'name{suffix}': alias_prefix + alias}
|
Q(**{f'name{suffix}': alias_prefix + alias})
|
||||||
).union(
|
| Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
||||||
queryset.filter(
|
| Q(**{f'normalized_name{suffix}': alias_prefix + alias.lower()})
|
||||||
Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
)
|
||||||
& ~Q(**{f'name{suffix}': alias_prefix + alias})
|
|
||||||
),
|
|
||||||
all=True).union(
|
|
||||||
queryset.filter(
|
|
||||||
Q(**{f'normalized_name{suffix}': alias_prefix + alias.lower()})
|
|
||||||
& ~Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
|
||||||
& ~Q(**{f'name{suffix}': alias_prefix + 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")
|
||||||
|
|
|
@ -5,7 +5,6 @@ from django import forms
|
||||||
from django.contrib.auth.forms import UserCreationForm
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from member.models import Club
|
|
||||||
from note.models import NoteSpecial, Alias
|
from note.models import NoteSpecial, Alias
|
||||||
from note_kfet.inputs import AmountInput
|
from note_kfet.inputs import AmountInput
|
||||||
|
|
||||||
|
@ -115,12 +114,3 @@ class ValidationForm(forms.Form):
|
||||||
required=False,
|
required=False,
|
||||||
initial=True,
|
initial=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# If the bda exists
|
|
||||||
if Club.objects.filter(name__iexact="bda").exists():
|
|
||||||
# The user can join the bda club at the inscription
|
|
||||||
join_bda = forms.BooleanField(
|
|
||||||
label=_("Join BDA Club"),
|
|
||||||
required=False,
|
|
||||||
initial=True,
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue