mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.5 KiB
37 lines
1.5 KiB
from django.utils.translation import ugettext as _
|
|
from rest_framework import serializers
|
|
from common.drf.fields import ReadableHiddenField
|
|
from ops.mixin import PeriodTaskSerializerMixin
|
|
from ops.models import Job, JobExecution
|
|
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
|
|
|
|
|
class JobSerializer(BulkOrgResourceModelSerializer, PeriodTaskSerializerMixin):
|
|
owner = ReadableHiddenField(default=serializers.CurrentUserDefault())
|
|
run_after_save = serializers.BooleanField(label=_("Run after save"), read_only=True, default=False, required=False)
|
|
|
|
class Meta:
|
|
model = Job
|
|
read_only_fields = ["id", "date_last_run", "date_created", "date_updated", "average_time_cost",
|
|
"run_after_save"]
|
|
fields = read_only_fields + [
|
|
"name", "instant", "type", "module", "args", "playbook", "assets", "runas_policy", "runas", "owner",
|
|
"use_parameter_define",
|
|
"parameters_define",
|
|
"timeout",
|
|
"chdir",
|
|
"comment",
|
|
"summary",
|
|
"is_periodic", "interval", "crontab"
|
|
]
|
|
|
|
|
|
class JobExecutionSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = JobExecution
|
|
read_only_fields = ["id", "task_id", "timedelta", "time_cost", 'is_finished', 'date_start', 'date_created',
|
|
'is_success', 'task_id', 'short_id', 'job_type']
|
|
fields = read_only_fields + [
|
|
"job", "parameters"
|
|
]
|