2018-01-14 12:19:11 +00:00
|
|
|
from django.db import models
|
2018-01-20 02:41:29 +00:00
|
|
|
from django.core import validators
|
2018-01-21 00:10:32 +00:00
|
|
|
from content.models import School, Category, Video
|
2018-01-14 12:19:11 +00:00
|
|
|
|
2018-01-21 00:10:32 +00:00
|
|
|
class Voter(models.Model):
|
2018-01-20 02:41:29 +00:00
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
firstname = models.CharField(max_length=100)
|
|
|
|
email = models.EmailField(max_length=200)
|
2018-01-21 00:10:32 +00:00
|
|
|
ecole = models.ForeignKey('content.School', on_delete=models.CASCADE)
|
2018-01-20 02:41:29 +00:00
|
|
|
password = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.firstname + " " + self.name
|
|
|
|
|
2018-01-21 00:10:32 +00:00
|
|
|
|
|
|
|
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)
|
2018-01-20 02:41:29 +00:00
|
|
|
vote = models.IntegerField(
|
2018-01-21 00:10:32 +00:00
|
|
|
validators=[
|
|
|
|
validators.MaxValueValidator(5),
|
|
|
|
validators.MinValueValidator(0)
|
|
|
|
]
|
2018-01-20 02:41:29 +00:00
|
|
|
)
|