Skip to content
Snippets Groups Projects
Commit 1ef6c791 authored by Julien Schmidt's avatar Julien Schmidt
Browse files

fix number of max votes

parent 7eb0f329
No related branches found
No related tags found
No related merge requests found
Pipeline #468 passed
......@@ -113,6 +113,8 @@ class VoteForm(forms.Form):
for application in self.election.applications:
self.fields[f'{application.pk}'] = VoteField(application=application)
self.num_applications = len(self.election.applications)
def clean(self):
super().clean()
if not self.voter.can_vote:
......
......@@ -47,10 +47,11 @@ def code_login(request, access_code=None):
@voter_login_required
def index(request):
voter = request.user
max_votes_yes = voter.election.max_votes_yes
context = {
'title': voter.election.title,
'max_votes_yes': voter.election.max_votes_yes,
'max_votes_yes': max_votes_yes,
'voter': voter,
}
......@@ -68,10 +69,11 @@ def index(request):
if form.is_valid():
form.save()
return redirect('vote:index')
context['form'] = form
else:
context['form'] = VoteForm(request)
form = VoteForm(request)
context['form'] = form
context['max_votes_yes'] = min(max_votes_yes, form.num_applications)
return render(request, template_name='vote/vote.html', context=context)
# overview
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment