Updated polls/models to include a field for storing the ballot selected by the user on the front end. A few bugs have been fixed on the event voting page and new functionality has been added which allows a voter to restart the voting process.
This commit is contained in:
parent
bab4aa29cf
commit
572600408c
5 changed files with 81 additions and 26 deletions
|
@ -205,6 +205,7 @@ class PartialBallotDecryption(models.Model):
|
|||
class Ballot(models.Model):
|
||||
voter = models.ForeignKey(EmailUser, on_delete=models.CASCADE, related_name="ballots")
|
||||
poll = models.ForeignKey(Poll, on_delete=models.CASCADE, related_name="ballots")
|
||||
selection = models.CharField(max_length=1)
|
||||
cast = models.BooleanField(default=False)
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ class EventDetailView(generic.DetailView):
|
|||
for poll in polls:
|
||||
result_json = poll.result_json
|
||||
|
||||
if result_json is None:
|
||||
continue
|
||||
|
||||
if result_json[len(result_json)-1] == ',':
|
||||
result_json = result_json[0:len(result_json)-1]
|
||||
|
||||
|
@ -173,6 +176,7 @@ def event_vote(request, event_id, poll_id):
|
|||
|
||||
if request.method == "POST":
|
||||
data = json.loads(request.POST.lists()[0][0])
|
||||
selection = data['selection']
|
||||
ballot_json = data['ballot']
|
||||
encrypted_votes_json = ballot_json['encryptedVotes']
|
||||
|
||||
|
@ -191,6 +195,7 @@ def event_vote(request, event_id, poll_id):
|
|||
cipher_text_c2=fragment['C2'])
|
||||
|
||||
ballot.cast = True
|
||||
ballot.selection = selection
|
||||
ballot.save()
|
||||
|
||||
combine_encrypted_votes.delay(email_key[0].user, poll)
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
</div>
|
||||
<span><strong>Voting status:</strong>
|
||||
{% if has_voted %}
|
||||
Voted - Re-Submitting will Change your Vote
|
||||
<span style="color: green; font-weight: bold">Voted - Re-submitting will change your vote</span>
|
||||
{% else %}
|
||||
Not Voted
|
||||
<span style="color: red; font-weight: bold">Not Voted</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
<br/>
|
||||
|
@ -104,13 +104,12 @@
|
|||
</div>
|
||||
|
||||
<!-- Information Dialog called upon request -->
|
||||
<div class="modal fade" id="modalDialog" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal fade" id="modalDialog" role="dialog" tabindex="-1" data-backdrop="static">
|
||||
<div class="modal-dialog" role="document">
|
||||
|
||||
<!-- Dialog content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title" style="text-align: center"><strong>Please Select a Ballot</strong></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
@ -124,7 +123,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
{% comment %}<button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>{% endcomment %}
|
||||
<button id="cancelVoteBtn" type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
|
||||
<button id="closeDialogBtn" type="button" class="btn btn-primary hidden" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Reference in a new issue