mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-05 23:18:53 -05:00
fix
This commit is contained in:
parent
496285e9e1
commit
8c73633429
@ -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
@ -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":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user