mirror of https://github.com/jumpserver/jumpserver
parent
3c043a2233
commit
f8ac83d5c7
|
@ -7,7 +7,8 @@ from assets.models import Asset, Node, BaseAutomation
|
||||||
from accounts.models import AutomationExecution
|
from accounts.models import AutomationExecution
|
||||||
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
from common.serializers.fields import ObjectRelatedField
|
from common.const.choices import Trigger
|
||||||
|
from common.serializers.fields import ObjectRelatedField, LabeledChoiceField
|
||||||
|
|
||||||
logger = get_logger(__file__)
|
logger = get_logger(__file__)
|
||||||
|
|
||||||
|
@ -40,14 +41,14 @@ class BaseAutomationSerializer(PeriodTaskSerializerMixin, BulkOrgResourceModelSe
|
||||||
class AutomationExecutionSerializer(serializers.ModelSerializer):
|
class AutomationExecutionSerializer(serializers.ModelSerializer):
|
||||||
snapshot = serializers.SerializerMethodField(label=_('Automation snapshot'))
|
snapshot = serializers.SerializerMethodField(label=_('Automation snapshot'))
|
||||||
type = serializers.ChoiceField(choices=AutomationTypes.choices, write_only=True, label=_('Type'))
|
type = serializers.ChoiceField(choices=AutomationTypes.choices, write_only=True, label=_('Type'))
|
||||||
trigger_display = serializers.ReadOnlyField(source='get_trigger_display', label=_('Trigger mode'))
|
trigger = LabeledChoiceField(choices=Trigger.choices, read_only=True, label=_("Trigger mode"))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AutomationExecution
|
model = AutomationExecution
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
'trigger_display', 'date_start', 'date_finished', 'snapshot', 'status'
|
'trigger', 'date_start', 'date_finished', 'snapshot', 'status'
|
||||||
]
|
]
|
||||||
fields = ['id', 'automation', 'trigger', 'type'] + read_only_fields
|
fields = ['id', 'automation', 'type'] + read_only_fields
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_snapshot(obj):
|
def get_snapshot(obj):
|
||||||
|
|
|
@ -37,14 +37,14 @@ class BaseAutomationSerializer(PeriodTaskSerializerMixin, BulkOrgResourceModelSe
|
||||||
|
|
||||||
class AutomationExecutionSerializer(serializers.ModelSerializer):
|
class AutomationExecutionSerializer(serializers.ModelSerializer):
|
||||||
snapshot = serializers.SerializerMethodField(label=_('Automation snapshot'))
|
snapshot = serializers.SerializerMethodField(label=_('Automation snapshot'))
|
||||||
trigger = LabeledChoiceField(choices=Trigger.choices, label=_("Trigger mode"))
|
trigger = LabeledChoiceField(choices=Trigger.choices, read_only=True, label=_("Trigger mode"))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AutomationExecution
|
model = AutomationExecution
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
'trigger', 'date_start', 'date_finished', 'snapshot', 'status'
|
'trigger', 'date_start', 'date_finished', 'snapshot', 'status'
|
||||||
]
|
]
|
||||||
fields = ['id', 'automation', 'trigger'] + read_only_fields
|
fields = ['id', 'automation'] + read_only_fields
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_snapshot(obj):
|
def get_snapshot(obj):
|
||||||
|
|
Loading…
Reference in New Issue