From b14742205b543eeb8ad5ad74a4e698974ef02123 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Tue, 6 Sep 2011 09:40:48 +0200 Subject: [PATCH] unique candidates in assignments if there are more then one ballot --- openslides/assignment/models.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openslides/assignment/models.py b/openslides/assignment/models.py index 3e42d6a2a..b8fb105d2 100644 --- a/openslides/assignment/models.py +++ b/openslides/assignment/models.py @@ -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: