Skip to content

Commit 6c342e0

Browse files
committed
refactor: add all user list
1 parent a9381ab commit 6c342e0

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

apps/users/serializers/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ def batch_delete(self, with_valid=True):
479479
User.objects.filter(id__in=ids).delete()
480480
return True
481481

482+
def get_all_user_list(self):
483+
users = User.objects.all().values('id', 'nick_name', 'username')
484+
return list(users)
485+
482486

483487
def update_user_role(instance, user):
484488
workspace_user_role_mapping_model = DatabaseModelManage.get_model("workspace_user_role_mapping")

apps/users/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
path("user/re_password", views.RePasswordView.as_view(), name='re_password'),
1515
path("user/current/send_email", views.SendEmailToCurrentUserView.as_view(), name="send_email_current"),
1616
path("user/current/reset_password", views.ResetCurrentUserPasswordView.as_view(), name="reset_password_current"),
17+
path("user/list", views.UserList.as_view(), name="current_user_profile"),
1718
path('workspace/<str:workspace_id>/user_list', views.WorkspaceUserListView.as_view(),
1819
name="test_workspace_id_permission"),
1920
path('workspace/<str:workspace_id>/user_member',views.WorkspaceUserMemberView.as_view(),

apps/users/views/user.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ def get(self, request: Request, workspace_id):
9696
return result.success(UserProfileSerializer().profile(request.user, request.auth))
9797

9898

99+
class UserList(APIView):
100+
authentication_classes = [TokenAuth]
101+
102+
@extend_schema(methods=['GET'],
103+
summary=_("Get all user"),
104+
description=_("Get all user"),
105+
operation_id=_("Get all user"), # type: ignore
106+
tags=[_("User Management")], # type: ignore
107+
responses=UserListApi.get_response())
108+
def get(self, request: Request):
109+
return result.success(UserManageSerializer().get_all_user_list())
110+
111+
99112
class WorkspaceUserListView(APIView):
100113
authentication_classes = [TokenAuth]
101114

0 commit comments

Comments
 (0)