merge error

This commit is contained in:
Oskar Hahn 2011-09-03 11:56:35 +02:00
parent f5d2a503d0
commit 98ee433cd3
2 changed files with 28 additions and 15 deletions

View File

@ -114,7 +114,7 @@ class Assignment(models.Model):
poll.assignment = self poll.assignment = self
poll.description = self.polldescription poll.description = self.polldescription
poll.save() poll.save()
for candidate in candidates: for candidate in candidates:
poll.add_option(candidate) poll.add_option(candidate)
return poll return poll

View File

@ -65,24 +65,18 @@ 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()
# list of candidates
candidates = set()
for option in Option.objects.filter(poll__assignment=assignment):
candidates.add(option.value)
votes = [] votes = []
for candidate in candidates: for candidate in assignment.candidates:
tmplist = [] tmplist = [[candidate, assignment.is_elected(candidate)], []]
tmplist.append(candidate)
for poll in assignment.poll_set.all(): for poll in assignment.poll_set.all():
if candidate in poll.options_values: if candidate in poll.options_values:
option = Option.objects.filter(poll=poll).filter(user=candidate)[0] option = Option.objects.filter(poll=poll).filter(user=candidate)[0]
if poll.optiondecision: if poll.optiondecision:
tmplist.append([option.yes, option.no, option.undesided]) tmplist[1].append([option.yes, option.no, option.undesided])
else: else:
tmplist.append(option.yes) tmplist[1].append(option.yes)
else: else:
tmplist.append("-") tmplist[1].append("-")
votes.append(tmplist) votes.append(tmplist)
return {'assignment': assignment, return {'assignment': assignment,
@ -241,3 +235,22 @@ def delete_poll(request, poll_id):
else: else:
del_confirm_form(request, poll, name=_("the %s. ballot") % ballot) del_confirm_form(request, poll, name=_("the %s. ballot") % ballot)
return redirect(reverse('assignment_view', args=[assignment.id])) return redirect(reverse('assignment_view', args=[assignment.id]))
@permission_required('assignment.can_manage_assignment')
def set_elected(request, assignment_id, profile_id, elected=True):
assignment = Assignment.objects.get(pk=assignment_id)
profile = Profile.objects.get(pk=profile_id)
assignment.set_elected(profile, elected)
if request.is_ajax():
if elected:
link = reverse('assignment_user_not_elected', args=[assignment.id, profile.id])
text = _('not elected')
else:
link = reverse('assignment_user_elected', args=[assignment.id, profile.id])
text = _('elected')
return ajax_request({'elected': elected,
'link': link,
'text': text})
return redirect(reverse('assignment_view', args=[assignment_id]))