From f8ac83d5c7562f634c551f10e0fa6d81fae25b44 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:54:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20change=20secret=20trigger=20=E5=BF=85?= =?UTF-8?q?=E5=A1=AB=20(#9333)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/accounts/serializers/automations/base.py | 9 +++++---- apps/assets/serializers/automations/base.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/accounts/serializers/automations/base.py b/apps/accounts/serializers/automations/base.py index 8c11e8966..0939558e1 100644 --- a/apps/accounts/serializers/automations/base.py +++ b/apps/accounts/serializers/automations/base.py @@ -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): diff --git a/apps/assets/serializers/automations/base.py b/apps/assets/serializers/automations/base.py index fa20c4c28..804bcabc9 100644 --- a/apps/assets/serializers/automations/base.py +++ b/apps/assets/serializers/automations/base.py @@ -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):