(backend) enhance search users to add in a team

Exclude from the result all users already members of the current team
This commit is contained in:
Sabrina Demagny
2024-03-22 13:36:54 +01:00
parent e9a628f816
commit 775b32ff45
2 changed files with 62 additions and 0 deletions

View File

@@ -206,6 +206,10 @@ class UserViewSet(
)
)
# Exclude all users already in the given team
if team_id := self.request.GET.get("team_id", ""):
queryset = queryset.exclude(teams__id=team_id)
# Search by case-insensitive and accent-insensitive trigram similarity
if query := self.request.GET.get("q", ""):
similarity = Max(