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']