21 lines
640 B
Python
21 lines
640 B
Python
from rest_framework import serializers
|
|
from .models import FlowDefinition, FlowExecutionLog
|
|
from .engine import validate_flow_dag
|
|
|
|
|
|
class FlowDefinitionSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = FlowDefinition
|
|
fields = '__all__'
|
|
read_only_fields = ['id', 'created_by', 'created_at', 'updated_at']
|
|
|
|
def validate_graph(self, value):
|
|
validate_flow_dag(value)
|
|
return value
|
|
|
|
|
|
class FlowExecutionLogSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = FlowExecutionLog
|
|
fields = '__all__'
|
|
read_only_fields = ['id', 'started_at', 'completed_at']
|