This commit is contained in:
Markos Gogoulos 2025-10-25 17:18:46 +03:00
parent 496285e9e1
commit 8c73633429
3 changed files with 8 additions and 2 deletions

View File

@ -87,7 +87,7 @@ export const BulkActionPermissionModal: React.FC<BulkActionPermissionModalProps>
}
try {
const response = await fetch(`/api/v1/users?name=${encodeURIComponent(name)}`);
const response = await fetch(`/api/v1/users?name=${encodeURIComponent(name)}&exclude_self=True`);
if (!response.ok) {
throw new Error(translateString('Failed to search users'));
}

File diff suppressed because one or more lines are too long

View File

@ -206,6 +206,7 @@ class UserList(APIView):
manual_parameters=[
openapi.Parameter(name='page', type=openapi.TYPE_INTEGER, in_=openapi.IN_QUERY, description='Page number'),
openapi.Parameter(name='name', type=openapi.TYPE_STRING, in_=openapi.IN_QUERY, description='Search by name or username'),
openapi.Parameter(name='exclude_self', type=openapi.TYPE_BOOLEAN, in_=openapi.IN_QUERY, description='Exclude current user from results'),
],
tags=['Users'],
operation_summary='List users',
@ -226,6 +227,11 @@ class UserList(APIView):
if name:
users = users.filter(Q(name__icontains=name) | Q(username__icontains=name))
# Exclude current user if requested
exclude_self = request.GET.get("exclude_self", "") == "True"
if exclude_self and request.user.is_authenticated:
users = users.exclude(id=request.user.id)
if settings.USERS_NEEDS_TO_BE_APPROVED:
is_approved = request.GET.get("is_approved")
if is_approved == "true":