|
|
|
@ -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): |
|
|
|
|