from django import forms
from django.forms import ModelForm, formset_factory

from .models import Account, Player, Preferences


class PreferencesForm(ModelForm):
    season_id = ""

    class Meta:
        model = Preferences
        fields = ["user", "managed_team"]
        widgets = {
            "user": forms.HiddenInput(),
        }


class AccountForm(ModelForm):
    class Meta:
        model = Account
        fields = ["user", "email", "password"]
        widgets = {
            "user": forms.HiddenInput(),
            "email": forms.EmailInput(),
            "password": forms.PasswordInput(),
        }


class PlayerForm(ModelForm):
    gamechanger_name = forms.Field()
    teamsnap_name = forms.Field()
    fname = forms.Field()
    lname = forms.Field()

    class Meta:
        model = Player
        fields = ["id", "teamsnap_member_id"]
        widgets = {
            "teamsnap_member_id": forms.Select(
                choices=(), attrs={"class": "form-control"}
            ),
        }


PlayerFormSet = formset_factory(PlayerForm, can_delete=True, extra=0)
