adds vote posting

also moves some validation code to the model
This commit is contained in:
2025-05-22 15:17:35 +02:00
parent 501044eef2
commit 3de8234fb9
7 changed files with 49 additions and 10 deletions
+2 -1
View File
@@ -1,10 +1,11 @@
from django.db import models
from django.contrib.auth.models import User
from django.core.validators import MinValueValidator, MaxValueValidator
class Vote(models.Model):
class Meta:
unique_together = ["user", "track"]
track = models.ForeignKey('Track', on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
points = models.IntegerField()
points = models.IntegerField(validators=[MinValueValidator(1), MaxValueValidator(5)])
skipped = models.BooleanField(default=False)