site_tps/vote/models.py
2018-01-22 14:25:19 +01:00

21 lines
657 B
Python

from django.db import models
from django.core import validators
from content.models import Content
from django.contrib.auth.models import Group, User
class Vote(models.Model):
votant = models.ForeignKey(User, on_delete=models.CASCADE)
content = models.ForeignKey(Content, on_delete=models.CASCADE)
vote = models.IntegerField(
validators=[
validators.MaxValueValidator(5),
validators.MinValueValidator(0)
]
)
class Poll(models.Model):
voters_group = models.ForeignKey(Group, on_delete=models.CASCADE)
contents = models.ManyToManyField(Content)
title = models.CharField(max_length=1024)