From feeb99041fe42d6cfb97794d3e989467fc85f5a8 Mon Sep 17 00:00:00 2001 From: korenstin Date: Sat, 13 Jul 2024 12:41:59 +0200 Subject: [PATCH] Fix the Alias Search API --- apps/note/api/views.py | 17 ++++------------- apps/registration/forms.py | 10 ---------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/apps/note/api/views.py b/apps/note/api/views.py index bc4f99ef..32ed1837 100644 --- a/apps/note/api/views.py +++ b/apps/note/api/views.py @@ -179,19 +179,10 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet): # We match first an alias if it is matched without normalization, # then if the normalized pattern matches a normalized alias. queryset = queryset.filter( - **{f'name{suffix}': alias_prefix + alias} - ).union( - queryset.filter( - 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) + Q(**{f'name{suffix}': alias_prefix + alias}) + | Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)}) + | Q(**{f'normalized_name{suffix}': alias_prefix + alias.lower()}) + ) queryset = queryset if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' \ else queryset.order_by("name") diff --git a/apps/registration/forms.py b/apps/registration/forms.py index 6761da43..7791a8a1 100644 --- a/apps/registration/forms.py +++ b/apps/registration/forms.py @@ -5,7 +5,6 @@ from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User from django.utils.translation import gettext_lazy as _ -from member.models import Club from note.models import NoteSpecial, Alias from note_kfet.inputs import AmountInput @@ -115,12 +114,3 @@ class ValidationForm(forms.Form): required=False, 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, - )