From feeb99041fe42d6cfb97794d3e989467fc85f5a8 Mon Sep 17 00:00:00 2001 From: korenstin Date: Sat, 13 Jul 2024 12:41:59 +0200 Subject: [PATCH 1/2] 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, - ) From bbbdcc7247fe1539e1aa9eb48f447a4e6fae7472 Mon Sep 17 00:00:00 2001 From: korenstin Date: Sat, 13 Jul 2024 18:03:19 +0200 Subject: [PATCH 2/2] linters --- apps/permission/scopes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/permission/scopes.py b/apps/permission/scopes.py index f8fd7687..6770c681 100644 --- a/apps/permission/scopes.py +++ b/apps/permission/scopes.py @@ -35,6 +35,8 @@ class PermissionScopes(BaseScopes): class PermissionOAuth2Validator(OAuth2Validator): + oidc_claim_scope = None # fix breaking change of django-oauth-toolkit 2.0.0 + def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs): """ User can request as many scope as he wants, including invalid scopes, @@ -44,8 +46,6 @@ class PermissionOAuth2Validator(OAuth2Validator): subset of permissions. """ - oidc_claim_scope = None # fix breaking change of django-oauth-toolkit 2.0.0 - valid_scopes = set() for t in Permission.PERMISSION_TYPES: