Simplify models

This commit is contained in:
Ludovic Stephan 2020-11-20 14:55:31 +01:00
parent f3920957eb
commit b7a0d41db2

View file

@ -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)