Example #1
0
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
Example #2
0
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")
Example #3
0
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')
Example #4
0
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")
Example #5
0
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
Example #6
0
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
Example #7
0
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