fix problem by the assignment-poll view
This commit is contained in:
parent
6c66e55fc0
commit
5311c7ae31
@ -107,6 +107,7 @@ class Assignment(models.Model, SlideMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def vote_results(self):
|
def vote_results(self):
|
||||||
|
# TODO: Rewrite this code. Use a matrix and transform it.
|
||||||
votes = []
|
votes = []
|
||||||
publish_winner_results_only = config["assignment_publish_winner_results_only"]
|
publish_winner_results_only = config["assignment_publish_winner_results_only"]
|
||||||
# list of votes
|
# list of votes
|
||||||
@ -190,7 +191,7 @@ class AssignmentPoll(BasePoll, CountInvalid, CountVotesCast, PublishPollMixin):
|
|||||||
return self.assignment
|
return self.assignment
|
||||||
|
|
||||||
def get_vote_values(self):
|
def get_vote_values(self):
|
||||||
if not self.yesnoababstain:
|
if self.yesnoababstain is None:
|
||||||
if config['assignment_poll_vote_values'] == 'votes':
|
if config['assignment_poll_vote_values'] == 'votes':
|
||||||
self.yesnoababstain = False
|
self.yesnoababstain = False
|
||||||
elif config['assignment_poll_vote_values'] == 'yesnoabstain':
|
elif config['assignment_poll_vote_values'] == 'yesnoabstain':
|
||||||
|
@ -84,9 +84,14 @@ 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()
|
||||||
|
|
||||||
|
# why not use assignment.vote_results?
|
||||||
polls = assignment.poll_set.all()
|
polls = assignment.poll_set.all()
|
||||||
votes = []
|
votes = []
|
||||||
for candidate in assignment.candidates:
|
options = []
|
||||||
|
for poll in polls:
|
||||||
|
options += poll.get_options()
|
||||||
|
|
||||||
|
for candidate in set([option.candidate for option in options]):
|
||||||
tmplist = ((candidate, assignment.is_elected(candidate)), [])
|
tmplist = ((candidate, assignment.is_elected(candidate)), [])
|
||||||
for poll in polls:
|
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'):
|
||||||
@ -100,7 +105,6 @@ def view(request, assignment_id=None):
|
|||||||
else:
|
else:
|
||||||
tmplist[1].append("-")
|
tmplist[1].append("-")
|
||||||
votes.append(tmplist)
|
votes.append(tmplist)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'assignment': assignment,
|
'assignment': assignment,
|
||||||
'form': form,
|
'form': form,
|
||||||
|
Loading…
Reference in New Issue
Block a user