site_tps/vote/models.py

25 lines
881 B
Python

from django.db import models
from django.core import validators
from content.models import School, Category, Video
class Voter(models.Model):
name = models.CharField(max_length=100)
firstname = models.CharField(max_length=100)
email = models.EmailField(max_length=200)
ecole = models.ForeignKey('content.School', on_delete=models.CASCADE)
password = models.CharField(max_length=100)
def __str__(self):
return self.firstname + " " + self.name
class Vote(models.Model):
votant = models.ForeignKey('Voter', on_delete=models.CASCADE)
video = models.ForeignKey('content.Video', on_delete=models.CASCADE)
categorie = models.ForeignKey('content.Category', on_delete=models.CASCADE)
vote = models.IntegerField(
validators=[
validators.MaxValueValidator(5),
validators.MinValueValidator(0)
]
)