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-22 13:10:37 +00:00
|
|
|
from content.models import Content
|
|
|
|
from django.contrib.auth.models import Group, User
|
2018-01-20 02:41:29 +00:00
|
|
|
|
2018-01-21 00:10:32 +00:00
|
|
|
|
2018-01-22 21:11:16 +00:00
|
|
|
class Poll(models.Model):
|
|
|
|
voters_group = models.ForeignKey(Group, on_delete=models.CASCADE)
|
|
|
|
contents = models.ManyToManyField(Content)
|
|
|
|
title = models.CharField(max_length=1024)
|
|
|
|
|
|
|
|
|
2018-01-21 00:10:32 +00:00
|
|
|
class Vote(models.Model):
|
2018-01-22 13:10:37 +00:00
|
|
|
votant = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
|
|
content = models.ForeignKey(Content, on_delete=models.CASCADE)
|
2018-01-22 21:11:16 +00:00
|
|
|
poll = models.ForeignKey(Poll, 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
|
|
|
)
|