unique candidates in assignments if there are more then one ballot
This commit is contained in:
parent
3c42b26d6f
commit
b14742205b
@ -72,10 +72,18 @@ class Assignment(models.Model):
|
||||
# list of candidates
|
||||
from poll.models import Option
|
||||
candidates = []
|
||||
#for option in Option.objects.values('user__user__profile').filter(poll__assignment=self).order_by('user__user__first_name').distinct():
|
||||
|
||||
def unique(candidates):
|
||||
newcandidates = []
|
||||
for candidate in candidates:
|
||||
if not candidate in newcandidates:
|
||||
newcandidates.append(candidate)
|
||||
return newcandidates
|
||||
|
||||
|
||||
for option in Option.objects.filter(poll__assignment=self).order_by('user__user__first_name'):
|
||||
candidates.append(option.value)
|
||||
return candidates
|
||||
return unique(candidates)
|
||||
|
||||
def set_elected(self, profile, value=True):
|
||||
if profile in self.candidates:
|
||||
|
Loading…
Reference in New Issue
Block a user