Skip to content

Commit

Permalink
feat: list data_source users #1159
Browse files Browse the repository at this point in the history
  • Loading branch information
Canway-shiisa committed Aug 23, 2023
1 parent 5a714f1 commit 81796bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/bk-user/bkuser/apis/web/data_source/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from bkuser.apps.data_source.models import DataSourceDepartmentUserRelation, DataSourceUser


class DataSourceSearchDepartmentsOutputSchema(serializers.Serializer):
class DataSourceSearchDepartmentsOutput(serializers.Serializer):
id = serializers.CharField(help_text="部门ID")
name = serializers.CharField(help_text="部门名称")

Expand All @@ -23,7 +23,7 @@ class UserSearchInputSLZ(serializers.Serializer):
username = serializers.CharField(required=False, help_text="用户名", allow_blank=True)


@swagger_serializer_method(serializer_or_field=DataSourceSearchDepartmentsOutputSchema(many=True))
@swagger_serializer_method(serializer_or_field=DataSourceSearchDepartmentsOutput(many=True))
class UserSearchOutputSLZ(serializers.Serializer):
id = serializers.CharField(help_text="用户ID")
username = serializers.CharField(help_text="用户名")
Expand All @@ -32,7 +32,7 @@ class UserSearchOutputSLZ(serializers.Serializer):
email = serializers.CharField(help_text="邮箱")
departments = serializers.SerializerMethodField(help_text="用户部门")

# TODO:考虑抽象一个函数 获取数据后传递到context
# FIXME:考虑抽象一个函数 获取数据后传递到context
def get_departments(self, obj: DataSourceUser):
return [
{"id": department_user_relation.department.id, "name": department_user_relation.department.name}
Expand Down
2 changes: 0 additions & 2 deletions src/bk-user/bkuser/apis/web/data_source/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
from bkuser.apis.web.data_source.serializers import UserSearchInputSLZ, UserSearchOutputSLZ
from bkuser.apps.data_source.models import DataSource, DataSourceUser
from bkuser.common.error_codes import error_codes
from bkuser.common.pagination import CustomPageNumberPagination


class DataSourceUserListCreateApi(generics.ListCreateAPIView):
pagination_class = CustomPageNumberPagination
serializer_class = UserSearchOutputSLZ

def get_queryset(self):
Expand Down

0 comments on commit 81796bf

Please sign in to comment.