database way for the last commit
This commit is contained in:
parent
b14742205b
commit
31550a4ca7
@ -69,21 +69,7 @@ class Assignment(models.Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def candidates(self):
|
def candidates(self):
|
||||||
# list of candidates
|
return Profile.objects.filter(option__poll__assignment=self).order_by('user__first_name').distinct()
|
||||||
from poll.models import Option
|
|
||||||
candidates = []
|
|
||||||
|
|
||||||
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 unique(candidates)
|
|
||||||
|
|
||||||
def set_elected(self, profile, value=True):
|
def set_elected(self, profile, value=True):
|
||||||
if profile in self.candidates:
|
if profile in self.candidates:
|
||||||
|
Loading…
Reference in New Issue
Block a user