from django.db import models
from django.contrib.auth.models import User
from django.core.validators import MinValueValidator, MaxValueValidator
from .session import Session

class Vote(models.Model):
    class Meta:
        unique_together = ["user", "track", "session"]
    track = models.ForeignKey('Track', on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    points = models.IntegerField(validators=[MinValueValidator(1), MaxValueValidator(5)])
    skipped = models.BooleanField(default=False)
    session = models.ForeignKey(Session, on_delete=models.CASCADE, null=True, default=None)
