from django import forms

from .models import Artista, Album, Song


class ArtistaForm(forms.ModelForm):
    class Meta:
        model = Artista
        fields = ['nombre', 'biografia', 'foto']

    nombre = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    biografia = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'form-control'}))


class AlbumForm(forms.ModelForm):
    class Meta:
        model = Album
        fields = ['name', 'artist', 'year', 'cover_image']

    # year = forms.DateField(
        # widget=forms.DateInput(attrs={'type': 'date', 'class': 'form-control'}))

    artist = forms.ModelChoiceField(
        queryset=Artista.objects.all(),
        widget=forms.Select(attrs={'class': 'form-control'}))


class SongForm(forms.ModelForm):
    class Meta:
        model = Song
        fields = ['title', 'artist', 'album', 'year', 'lyrics']

    artist = forms.ModelChoiceField(
        queryset=Artista.objects.all(),
        widget=forms.Select(attrs={'class': 'form-control'}))

    album = forms.ModelChoiceField(
        queryset=Album.objects.all(),  # habría que seleccionar los álbumes del artista
        widget=forms.Select(attrs={'class': 'form-control'}))
