"""This module holds api serializers for ``likes`` app."""

from rest_framework import serializers

from mtp.apps.api.serializers import NonDeletedListSerializer

from ..models import Like


class LikeSerializer(serializers.ModelSerializer):
    """Serializer for ``Like`` model."""

    class Meta:
        list_serializer_class = NonDeletedListSerializer
        model = Like
        fields = ('author', 'weight')


class LikeableSerializer(serializers.ModelSerializer):
    """Serializer for ``Likeable`` models. To use like a Mixin.

    Apply this mixin on a likeable model serializer to display its likes.

    """

    likes = LikeSerializer(many=True, read_only=True)

    class Meta:
        fields = ('likes',)
