From a3cddd5d346acc5cf538f3cd408c15870c84e636 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 17 Mar 2022 16:25:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/api.py | 3 ++- apps/ops/models/command.py | 4 ++++ apps/ops/serializers/adhoc.py | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/audits/api.py b/apps/audits/api.py index 8b30451a6..fb1efe989 100644 --- a/apps/audits/api.py +++ b/apps/audits/api.py @@ -132,7 +132,8 @@ class CommandExecutionHostRelationViewSet(OrgRelationMixin, OrgBulkModelViewSet) search_fields = ('asset__hostname', ) http_method_names = ['options', 'get'] rbac_perms = { - 'GET': 'ops.view_commandexecution' + 'GET': 'ops.view_commandexecution', + 'list': 'ops.view_commandexecution', } def get_queryset(self): diff --git a/apps/ops/models/command.py b/apps/ops/models/command.py index 66bd8ed28..b5a1f2292 100644 --- a/apps/ops/models/command.py +++ b/apps/ops/models/command.py @@ -55,6 +55,10 @@ class CommandExecution(OrgModelMixin): def user_display(self): return str(self.user) + @lazyproperty + def hosts_display(self): + return ','.join(self.hosts.all().values_list('hostname', flat=True)) + @property def result(self): if self._result: diff --git a/apps/ops/serializers/adhoc.py b/apps/ops/serializers/adhoc.py index 80619c34a..094abf958 100644 --- a/apps/ops/serializers/adhoc.py +++ b/apps/ops/serializers/adhoc.py @@ -136,8 +136,7 @@ class CommandExecutionSerializer(serializers.ModelSerializer): fields_mini = ['id'] fields_small = fields_mini + [ 'command', 'result', 'log_url', - 'is_finished', - 'date_created', 'date_finished' + 'is_finished', 'date_created', 'date_finished' ] fields_fk = ['run_as'] fields_m2m = ['hosts']