from django import forms
from django.db import models
from django.db.models import CharField, EmailField

from benchcoach.users.models import User


# Create your models here.
class Account(models.Model):
    user = models.OneToOneField(
        User, on_delete=models.CASCADE, related_name="gamechanger_account"
    )
    email = EmailField()
    password = CharField(max_length=255)


class Team(models.Model):
    id = models.CharField(primary_key=True, max_length=30)
    slug = CharField(max_length=30)
    season_slug = CharField(max_length=30)


class Preferences(models.Model):
    user = models.OneToOneField(
        User, on_delete=models.CASCADE, related_name="gamechanger_preferences"
    )
    managed_team = models.OneToOneField(Team, on_delete=models.CASCADE)

    class Meta:
        verbose_name_plural = "preferences"


class Player(models.Model):
    id = models.CharField(primary_key=True, max_length=30)
    teamsnap_member_id = models.IntegerField()
    fname = CharField(max_length=30)
    lname = CharField(max_length=30)

    widgets = {
        "teamsnap_member_id": forms.Select(choices=(), attrs={"class": "form-control"}),
    }
