fix: change secret trigger 必填 (#9333)

Co-authored-by: feng <1304903146@qq.com>
pull/9334/head
fit2bot 2 years ago committed by GitHub
parent 3c043a2233
commit f8ac83d5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,7 +7,8 @@ from assets.models import Asset, Node, BaseAutomation
from accounts.models import AutomationExecution
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
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__)
@ -40,14 +41,14 @@ class BaseAutomationSerializer(PeriodTaskSerializerMixin, BulkOrgResourceModelSe
class AutomationExecutionSerializer(serializers.ModelSerializer):
snapshot = serializers.SerializerMethodField(label=_('Automation snapshot'))
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:
model = AutomationExecution
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
def get_snapshot(obj):

@ -37,14 +37,14 @@ class BaseAutomationSerializer(PeriodTaskSerializerMixin, BulkOrgResourceModelSe
class AutomationExecutionSerializer(serializers.ModelSerializer):
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:
model = AutomationExecution
read_only_fields = [
'trigger', 'date_start', 'date_finished', 'snapshot', 'status'
]
fields = ['id', 'automation', 'trigger'] + read_only_fields
fields = ['id', 'automation'] + read_only_fields
@staticmethod
def get_snapshot(obj):

Loading…
Cancel
Save