Functionnal vote form

This commit is contained in:
2016-12-22 00:15:16 +01:00
parent e8ead338d0
commit 521b61517b
2 changed files with 43 additions and 21 deletions

View File

@ -36,13 +36,12 @@ class Election(models.Model):
now = timezone.now()
return bool(now <= self.end_candidature and now >= self.start_candidature)
def has_voted(self, user):
return False
# return self.has_voted.filter(id=user.id).exists()
def get_results(self):
pass
def has_voted(self, user):
return False
# Permissions
@ -56,6 +55,9 @@ class Role(models.Model):
has_voted = models.ManyToManyField(User, verbose_name=('has voted'), related_name='has_voted')
max_choice = models.IntegerField(_('max choice'), default=1)
def user_has_voted(self, user):
return not self.has_voted.filter(id=user.id).exists()
def __str__(self):
return ("%s : %s") % (self.election.title, self.title)