from django.db import models

from usuarios.models import Equipos


# Create your models here.
class TipoEvento(models.TextChoices):
    ENTRENAMIENTO = 'ENTRENAMIENTO', 'Entrenamiento'
    PARTIDO = 'PARTIDO', 'Partido'
    REUNION = 'REUNION', 'Reunión'
    ACTIVIDAD = 'ACTIVIDAD', 'Actividad'
    OTRO = 'OTRO', 'Otro'



class Evento(models.Model):
    id = models.AutoField(primary_key=True)
    equipo = models.ForeignKey(Equipos, on_delete=models.CASCADE, related_name='eventos')
    titulo = models.CharField(max_length=200)
    descripcion = models.TextField(blank=True)
    tipo = models.CharField(
        max_length=20,
        choices=TipoEvento.choices,
        default=TipoEvento.ENTRENAMIENTO
    )
    fecha_inicio = models.DateTimeField()
    fecha_fin = models.DateTimeField()
    ubicacion = models.CharField(max_length=200, blank=True)
    creado_en = models.DateTimeField(auto_now_add=True)
    actualizado_en = models.DateTimeField(auto_now=True)

    # Para eventos recurrentes (opcional)
    es_recurrente = models.BooleanField(default=False)
    frecuencia = models.CharField(max_length=20, blank=True)  # DIARIO, SEMANAL, MENSUAL

    class Meta:
        ordering = ['fecha_inicio']
        verbose_name = 'Evento'
        verbose_name_plural = 'Eventos'

    def __str__(self):
        return f"{self.titulo} - {self.equipo.description}"