baseline: 批次A-D 成果 + membership 半成品(测试红)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from rest_framework import serializers
|
||||
from apps.core.serializers import AsyncModelSerializer
|
||||
from .models import Notification, AlertRule
|
||||
|
||||
|
||||
class NotificationSerializer(AsyncModelSerializer):
|
||||
category_name = serializers.CharField(source="get_category_display", read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Notification
|
||||
fields = [
|
||||
"id", "title", "content", "category", "category_name",
|
||||
"link", "is_read", "read_at", "extra_data", "created_at",
|
||||
]
|
||||
read_only_fields = ["id", "created_at"]
|
||||
|
||||
|
||||
class AlertRuleSerializer(AsyncModelSerializer):
|
||||
rule_type_name = serializers.CharField(source="get_rule_type_display", read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = AlertRule
|
||||
fields = [
|
||||
"id", "code", "name", "rule_type", "rule_type_name",
|
||||
"threshold", "is_enabled", "channels", "created_at", "updated_at",
|
||||
]
|
||||
read_only_fields = ["id", "created_at", "updated_at"]
|
||||
Reference in New Issue
Block a user