58 lines
1.4 KiB
Python
58 lines
1.4 KiB
Python
from rest_framework import serializers
|
|
|
|
from .models import ChannelConfig, NotificationDispatch, NotificationTemplate
|
|
|
|
|
|
class NotificationTemplateSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = NotificationTemplate
|
|
fields = [
|
|
"id",
|
|
"slug",
|
|
"name",
|
|
"channel",
|
|
"subject_template",
|
|
"body_template",
|
|
"is_html",
|
|
"namespace",
|
|
"metadata",
|
|
]
|
|
read_only_fields = ["id"]
|
|
|
|
|
|
class NotificationDispatchSerializer(serializers.ModelSerializer):
|
|
template_info = NotificationTemplateSerializer(source="template", read_only=True)
|
|
|
|
class Meta:
|
|
model = NotificationDispatch
|
|
fields = [
|
|
"id",
|
|
"template",
|
|
"template_info",
|
|
"recipient",
|
|
"channel",
|
|
"subject",
|
|
"body",
|
|
"status",
|
|
"error_message",
|
|
"attempt",
|
|
"next_retry_at",
|
|
"context_snapshot",
|
|
"created_at",
|
|
"completed_at",
|
|
"request_id",
|
|
]
|
|
read_only_fields = fields
|
|
|
|
|
|
class ChannelConfigSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = ChannelConfig
|
|
fields = [
|
|
"slug",
|
|
"channel_type",
|
|
"display_name",
|
|
"config",
|
|
"is_active",
|
|
"priority",
|
|
]
|