From 5a0c5285e79ee3ced144c9263427dec692bbf9fe Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 8 Jan 2025 14:35:35 +0100 Subject: [PATCH] # 457 User autocomplete fix * fixes bug where empty query parameter would show users in autocomplete share view * fixes same behaviour on autocomplete share team view --- user/autocomplete/share.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/user/autocomplete/share.py b/user/autocomplete/share.py index 215e32c6..4e450286 100644 --- a/user/autocomplete/share.py +++ b/user/autocomplete/share.py @@ -17,10 +17,11 @@ class ShareUserAutocomplete(Select2QuerySetView): """ def get_queryset(self): + qs = User.objects.none() if self.request.user.is_anonymous: - return User.objects.none() - qs = User.objects.all() + return qs if self.q: + qs = User.objects.all() # Due to privacy concerns only a full username match will return the proper user entry qs = qs.filter( Q(username=self.q) | @@ -41,13 +42,13 @@ class ShareTeamAutocomplete(Select2QuerySetView): """ def get_queryset(self): + qs = Team.objects.none() if self.request.user.is_anonymous: - return Team.objects.none() - qs = Team.objects.filter( - deleted__isnull=True - ) + return qs if self.q: - # Due to privacy concerns only a full username match will return the proper user entry + qs = Team.objects.filter( + deleted__isnull=True + ) q_parts = self.q.split(" ") q = Q() for part in q_parts: -- 2.45.2