Simplify models
This commit is contained in:
parent
f3920957eb
commit
b7a0d41db2
1 changed files with 12 additions and 18 deletions
|
@ -17,31 +17,25 @@ class Election(models.Model):
|
||||||
User, on_delete=models.SET_NULL, blank=True, null=True
|
User, on_delete=models.SET_NULL, blank=True, null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
counted = models.BooleanField(_("dépouillée"), default=False)
|
|
||||||
results_public = models.BooleanField(_("résultats publics"), default=False)
|
results_public = models.BooleanField(_("résultats publics"), default=False)
|
||||||
|
tallied = models.BooleanField(_("dépouillée"), default=False)
|
||||||
|
|
||||||
archived = models.BooleanField(_("archivée"), default=False)
|
archived = models.BooleanField(_("archivée"), default=False)
|
||||||
|
|
||||||
|
|
||||||
class Question(models.Model):
|
class Question(models.Model):
|
||||||
election = models.ForeignKey(Election, on_delete=models.CASCADE)
|
election = models.ForeignKey(
|
||||||
|
Election, related_name="questions", on_delete=models.CASCADE
|
||||||
|
)
|
||||||
text = models.TextField(_("question"), blank=False)
|
text = models.TextField(_("question"), blank=False)
|
||||||
|
|
||||||
# TODO: add voting type
|
|
||||||
|
|
||||||
|
|
||||||
class Option(models.Model):
|
class Option(models.Model):
|
||||||
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
question = models.ForeignKey(
|
||||||
|
Question, related_name="options", on_delete=models.CASCADE
|
||||||
|
)
|
||||||
text = models.TextField(_("texte"), blank=False)
|
text = models.TextField(_("texte"), blank=False)
|
||||||
|
voters = models.ManyToManyField(
|
||||||
|
User,
|
||||||
class Vote(models.Model):
|
related_name="votes",
|
||||||
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
)
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
||||||
votes = models.ManyToManyField(Option, through="OptionVote")
|
|
||||||
|
|
||||||
|
|
||||||
class OptionVote(models.Model):
|
|
||||||
vote = models.ForeignKey(Vote, on_delete=models.CASCADE)
|
|
||||||
option = models.ForeignKey(Option, on_delete=models.CASCADE)
|
|
||||||
# Préparation pour condorcet ?
|
|
||||||
ranking = models.PositiveSmallIntegerField(_("rang"), default=0)
|
|
Loading…
Reference in a new issue