from . import BaseSerializer, serializers, timeAndImageRepresentation


class CategorySerializer(BaseSerializer):
    name = serializers.CharField(required=True)
    image = serializers.ImageField(allow_empty_file=True)

    def to_representation(self, instance):
        return {
            'id': instance.id,
            'name': instance.name,
            'podcast_count': instance.podcast_set.count(),
            **timeAndImageRepresentation(instance)
        }

from . import BaseSerializer, serializers, timeAndImageRepresentation


class CategorySerializer(BaseSerializer):
    name = serializers.CharField(required=True)
    image = serializers.ImageField(allow_empty_file=True)

    def to_representation(self, instance):
        return {
            'id': instance.id,
            'name': instance.name,
            'podcast_count': instance.podcast_set.count(),
            **timeAndImageRepresentation(instance)
        }
