feat: add AirShelf core implementation
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from .models import Notification
|
||||
|
||||
|
||||
class NotificationSerializer(serializers.ModelSerializer):
|
||||
type = serializers.CharField(source="notification_type", read_only=True)
|
||||
unread = serializers.SerializerMethodField()
|
||||
project_name = serializers.CharField(source="project.name", read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Notification
|
||||
fields = [
|
||||
"id",
|
||||
"type",
|
||||
"notification_type",
|
||||
"priority",
|
||||
"title",
|
||||
"brief",
|
||||
"body",
|
||||
"source",
|
||||
"project",
|
||||
"project_name",
|
||||
"stage",
|
||||
"owner_label",
|
||||
"cost_label",
|
||||
"related_url",
|
||||
"is_read",
|
||||
"unread",
|
||||
"read_at",
|
||||
"archived_at",
|
||||
"metadata",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
]
|
||||
read_only_fields = [
|
||||
"id",
|
||||
"type",
|
||||
"project_name",
|
||||
"read_at",
|
||||
"archived_at",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
]
|
||||
|
||||
def get_unread(self, obj):
|
||||
return not obj.is_read
|
||||
Reference in New Issue
Block a user