mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-24 21:08:30 +00:00
feat: 增加作业审计api
This commit is contained in:
@@ -3,9 +3,10 @@ from django.shortcuts import get_object_or_404
|
||||
from rest_framework.response import Response
|
||||
|
||||
from ops.models import Job, JobExecution
|
||||
from ops.models.job import JobAuditLog
|
||||
from ops.serializers.job import JobSerializer, JobExecutionSerializer
|
||||
|
||||
__all__ = ['JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView', 'JobAssetDetail']
|
||||
__all__ = ['JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView', 'JobAssetDetail', ]
|
||||
|
||||
from ops.tasks import run_ops_job_execution
|
||||
from ops.variables import JMS_JOB_VARIABLE_HELP
|
||||
|
@@ -9,7 +9,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
from celery import current_task
|
||||
|
||||
__all__ = ["Job", "JobExecution"]
|
||||
__all__ = ["Job", "JobExecution", "JobAuditLog"]
|
||||
|
||||
from ops.ansible import JMSInventory, AdHocRunner, PlaybookRunner
|
||||
from ops.mixin import PeriodTaskModelMixin
|
||||
@@ -286,3 +286,12 @@ class JobExecution(JMSOrgBaseModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['-date_created']
|
||||
|
||||
|
||||
class JobAuditLog(JobExecution):
|
||||
@property
|
||||
def creator_name(self):
|
||||
return self.creator.name
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
@@ -3,6 +3,7 @@ from rest_framework import serializers
|
||||
from common.drf.fields import ReadableHiddenField
|
||||
from ops.mixin import PeriodTaskSerializerMixin
|
||||
from ops.models import Job, JobExecution
|
||||
from ops.models.job import JobAuditLog
|
||||
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||
|
||||
|
||||
@@ -40,3 +41,6 @@ class JobExecutionSerializer(BulkOrgResourceModelSerializer):
|
||||
fields = read_only_fields + [
|
||||
"job", "parameters"
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user