class NotificationSerializer(ModelSerializer): """ Serializer of a notification object. """ content_type = SerializerMethodField() subscription = SubscriptionSerializer() sender = UserListSerializer() class Meta: model = Notification fields = ( "id", "title", "is_read", "url", "sender", "pubdate", "content_type", "subscription", ) permissions_classes = DRYPermissions def get_content_type(self, obj): return obj.content_type.model
class LikesSerializer(ModelSerializer): count = IntegerField(source="like", read_only=True) users = UserListSerializer(source="get_likers", many=True, read_only=True) class Meta: model = Comment fields = ("count", "users")
class LikesSerializer(ModelSerializer): count = IntegerField(source='like', read_only=True) users = UserListSerializer(source='get_likers', many=True, read_only=True) class Meta: model = Comment fields = ('count', 'users')
class PrivatePostDislikesSerializer(ModelSerializer): count = IntegerField(source="dislike", read_only=True) users = UserListSerializer(source="get_dislikers", many=True, read_only=True) class Meta: model = PrivatePost fields = ("count", "users")
class SubscriptionSerializer(ModelSerializer): """ Serializer of a subscription object. """ content_type = SerializerMethodField() user = UserListSerializer() class Meta: model = Subscription fields = ('id', 'user', 'is_active', 'by_email', 'content_type', 'pubdate', 'last_notification') permissions_classes = DRYPermissions def get_content_type(self, obj): return obj.content_type.model
class NotificationSerializer(ModelSerializer): """ Serializer of a notification object. """ content_type = SerializerMethodField() subscription = SubscriptionSerializer() sender = UserListSerializer() class Meta: model = Notification fields = ('id', 'title', 'is_read', 'url', 'sender', 'pubdate', 'content_type', 'subscription',) permissions_classes = DRYPermissions def get_content_type(self, obj): return obj.content_type.model
class SubscriptionSerializer(ModelSerializer): """ Serializer of a subscription object. """ content_type = SerializerMethodField() user = UserListSerializer() class Meta: model = Subscription fields = ("id", "user", "is_active", "by_email", "content_type", "pubdate", "last_notification") permissions_classes = DRYPermissions def get_content_type(self, obj): return obj.content_type.model