fixed problem in assignment poll

This commit is contained in:
Oskar Hahn 2012-04-15 14:58:05 +02:00
parent 91c9e1e9ab
commit a3808c7b30

View File

@ -76,10 +76,11 @@ def view(request, assignment_id=None):
if request.user.has_perm('assignment.can_nominate_other'): if request.user.has_perm('assignment.can_nominate_other'):
form = AssignmentRunForm() form = AssignmentRunForm()
polls = assignment.poll_set.all()
votes = [] votes = []
for candidate in assignment.candidates: for candidate in assignment.candidates:
tmplist = [[candidate, assignment.is_elected(candidate)], []] tmplist = ((candidate, assignment.is_elected(candidate)), [])
for poll in assignment.poll_set.all(): for poll in polls:
if (poll.published and not request.user.has_perm('assignment.can_manage_assignment')) or request.user.has_perm('assignment.can_manage_assignment'): if (poll.published and not request.user.has_perm('assignment.can_manage_assignment')) or request.user.has_perm('assignment.can_manage_assignment'):
# candidate exists in poll # candidate exists in poll
if poll.get_options().filter(candidate=candidate).exists(): if poll.get_options().filter(candidate=candidate).exists():
@ -92,8 +93,6 @@ def view(request, assignment_id=None):
tmplist[1].append("-") tmplist[1].append("-")
votes.append(tmplist) votes.append(tmplist)
polls = assignment.poll_set.all()
return { return {
'assignment': assignment, 'assignment': assignment,
'form': form, 'form': form,
@ -422,7 +421,7 @@ class AssignmentPDF(PDFView):
def get_assignment_votes(self, assignment): def get_assignment_votes(self, assignment):
votes = [] votes = []
for candidate in assignment.candidates: for candidate in assignment.candidates:
tmplist = [[candidate, assignment.is_elected(candidate)], []] tmplist = ((candidate, assignment.is_elected(candidate)), [])
for poll in assignment.poll_set.all(): for poll in assignment.poll_set.all():
if poll.published: if poll.published:
if poll.get_options().filter(candidate=candidate).exists(): if poll.get_options().filter(candidate=candidate).exists():