from taggit.serializers import TaggitSerializer, TagListSerializerField

from music.models import Album, Artist, Track
from rest_framework import serializers


class ArtistSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Artist
        fields = "__all__"


class AlbumSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Album
        fields = "__all__"


class TrackSerializer(TaggitSerializer, serializers.HyperlinkedModelSerializer):
    tags = TagListSerializerField()
    genre = TagListSerializerField()

    class Meta:
        model = Track
        fields = [
            "url",
            "id",
            "uuid",
            "title",
            "artist_fk",
            "artists",
            "album",
            "albums",
            "musicbrainz_id",
            "genre",
            "tags",
            "base_run_time_seconds",
            "created",
            "modified",
        ]
