perf: 可以获取多种协议类型的系统用户列表

pull/5400/head
Bai 2021-01-07 19:05:55 +08:00 committed by Jiangjie.Bai
parent e7a3c5a822
commit 19c2973501
3 changed files with 15 additions and 9 deletions

View File

@ -32,10 +32,15 @@ class AssetViewSet(FilterAssetByNodeMixin, OrgBulkModelViewSet):
API endpoint that allows Asset to be viewed or edited.
"""
model = Asset
filterset_fields = (
"hostname", "ip", "systemuser__id", "admin_user__id", "platform__base",
"is_active"
)
filterset_fields = {
'hostname': ['exact'],
'ip': ['exact'],
'systemuser__id': ['exact'],
'admin_user__id': ['exact'],
'platform__base': ['exact'],
'is_active': ['exact'],
'protocols': ['exact', 'icontains']
}
search_fields = ("hostname", "ip")
ordering_fields = ("hostname", "ip", "port", "cpu_cores")
serializer_classes = {

View File

@ -29,7 +29,11 @@ class SystemUserViewSet(OrgBulkModelViewSet):
System user api set, for add,delete,update,list,retrieve resource
"""
model = SystemUser
filterset_fields = ("name", "username", "protocol")
filterset_fields = {
'name': ['exact'],
'username': ['exact'],
'protocol': ['exact', 'in']
}
search_fields = filterset_fields
serializer_class = serializers.SystemUserSerializer
serializer_classes = {

View File

@ -32,10 +32,7 @@ __all__ = [
class UserViewSet(CommonApiMixin, UserQuerysetMixin, BulkModelViewSet):
filterset_fields = {
'name': ['exact', 'in']
}
# filterset_fields = ('username', 'email', 'name', 'id', 'source')
filterset_fields = ('username', 'email', 'name', 'id', 'source')
search_fields = filterset_fields
permission_classes = (IsOrgAdmin, CanUpdateDeleteUser)
serializer_classes = {