From 19c29735018ce8610b234647709ba17b404129b6 Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 7 Jan 2021 19:05:55 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=8F=AF=E4=BB=A5=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=A4=9A=E7=A7=8D=E5=8D=8F=E8=AE=AE=E7=B1=BB=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/asset.py | 13 +++++++++---- apps/assets/api/system_user.py | 6 +++++- apps/users/api/user.py | 5 +---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/assets/api/asset.py b/apps/assets/api/asset.py index fb86dad40..4de9fb899 100644 --- a/apps/assets/api/asset.py +++ b/apps/assets/api/asset.py @@ -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 = { diff --git a/apps/assets/api/system_user.py b/apps/assets/api/system_user.py index e799073d8..af7590579 100644 --- a/apps/assets/api/system_user.py +++ b/apps/assets/api/system_user.py @@ -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 = { diff --git a/apps/users/api/user.py b/apps/users/api/user.py index 672c90e88..1ac03af5e 100644 --- a/apps/users/api/user.py +++ b/apps/users/api/user.py @@ -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 = {