From 4dd6d4498b2c805b0180cd0fb0a8710808afb789 Mon Sep 17 00:00:00 2001 From: xinwen Date: Tue, 12 May 2020 17:09:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[Update]=20Asset=20filter=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20platform=5F=5Fname=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/asset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/assets/api/asset.py b/apps/assets/api/asset.py index 6eb8ebeaf..4bafe2fc2 100644 --- a/apps/assets/api/asset.py +++ b/apps/assets/api/asset.py @@ -33,7 +33,7 @@ class AssetViewSet(OrgBulkModelViewSet): API endpoint that allows Asset to be viewed or edited. """ model = Asset - filter_fields = ("hostname", "ip", "systemuser__id", "admin_user__id") + filter_fields = ("hostname", "ip", "systemuser__id", "admin_user__id", "platform__name") search_fields = ("hostname", "ip") ordering_fields = ("hostname", "ip", "port", "cpu_cores") serializer_classes = { From eb74d13059a3d277373ceb1af58b07c9db878b2d Mon Sep 17 00:00:00 2001 From: xinwen Date: Tue, 12 May 2020 17:09:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[Update]=20Asset=20filter=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20platform=5F=5Fbase=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/asset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/assets/api/asset.py b/apps/assets/api/asset.py index 4bafe2fc2..0d7a42454 100644 --- a/apps/assets/api/asset.py +++ b/apps/assets/api/asset.py @@ -33,7 +33,7 @@ class AssetViewSet(OrgBulkModelViewSet): API endpoint that allows Asset to be viewed or edited. """ model = Asset - filter_fields = ("hostname", "ip", "systemuser__id", "admin_user__id", "platform__name") + filter_fields = ("hostname", "ip", "systemuser__id", "admin_user__id", "platform__base") search_fields = ("hostname", "ip") ordering_fields = ("hostname", "ip", "port", "cpu_cores") serializer_classes = { From 9341ce9f844e20e0c7e56784ffd09e711f595382 Mon Sep 17 00:00:00 2001 From: Bai Date: Tue, 12 May 2020 20:31:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[Update]=20=E4=BF=AE=E5=A4=8DAssetUserViewS?= =?UTF-8?q?et=20=E4=BD=BF=E7=94=A8Option=E6=96=B9=E6=B3=95=E6=97=B6error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/asset_user.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/assets/api/asset_user.py b/apps/assets/api/asset_user.py index c0d834737..6e6af72ac 100644 --- a/apps/assets/api/asset_user.py +++ b/apps/assets/api/asset_user.py @@ -84,12 +84,15 @@ class AssetUserViewSet(CommonApiMixin, BulkModelViewSet): def get_object(self): pk = self.kwargs.get("pk") + if pk is None: + return queryset = self.get_queryset() obj = queryset.get(id=pk) return obj def get_exception_handler(self): def handler(e, context): + logger.error(e, exc_info=True) return Response({"error": str(e)}, status=400) return handler