Skip to content

Commit

Permalink
Disable Vote Button if they already voted
Browse files Browse the repository at this point in the history
  • Loading branch information
DrewRomanyk committed Feb 27, 2017
1 parent 7eac2a8 commit 957dc1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion texaslan/templates/voting/candidate_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1 class="panel-title">Officer Panel</h1>
</div>
</div>
{% endif %}
{% if voting_open %}
{% if voting_open and has_not_voted %}
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Actions</h1>
Expand Down
9 changes: 8 additions & 1 deletion texaslan/voting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.views.generic import ListView, CreateView, DetailView, FormView
from django.forms import ValidationError

from .models import Candidate, VoteBallot, CANDIDATE_POSITIONS, VoteService
from .models import Candidate, VoteBallot, CANDIDATE_POSITIONS, VoteService, VoteStatus
from .forms import StartElectionForm, CreateCandidateApplicationForm, VoteForm
from texaslan.utils.utils import ActiveRequiredMixin, HasNotAppliedRequiredMixin, HasNotVotedRequiredMixin
from texaslan.site_settings.models import SiteSettingService
Expand All @@ -24,6 +24,13 @@ def get_context_data(self, **kwargs):

context['voting_open'] = SiteSettingService.is_voting_currently()

context['has_not_voted'] = True
try:
VoteStatus.objects.get(voter__username=self.request.user.username)
context['has_not_voted'] = False
except VoteStatus.DoesNotExist:
pass

positions_list = []
for (position_code, position_name) in CANDIDATE_POSITIONS:
has_winner = False
Expand Down

0 comments on commit 957dc1f

Please sign in to comment.