Fixed a number of bugs that arose from merging the code from Bens fork. Added an extra step when voting which asks the user to confirm their voting choices. The voter now gets an email when they've successfully submitted thier vote.
This commit is contained in:
parent
fc0d0ea21c
commit
a168ba9e28
6 changed files with 281 additions and 75 deletions
|
@ -211,7 +211,7 @@ class Ballot(models.Model):
|
|||
|
||||
class EncBallot(models.Model):
|
||||
handle = models.CharField(primary_key=True, default=uuid.uuid4, editable=False, max_length=255)
|
||||
ballot = models.CharField(max_length=4096)
|
||||
ballot = models.CharField(max_length=10240)
|
||||
|
||||
|
||||
# Implements the new binary encoding scheme
|
||||
|
|
|
@ -212,6 +212,22 @@ def email_voters_vote_url(voters, event):
|
|||
voter.send_email(email_subject, email_body)
|
||||
|
||||
|
||||
@task()
|
||||
def email_voting_success(voter, ballotHandle, eventTitle):
|
||||
email_subject = "Vote(s) received for Event '" + eventTitle + "'"
|
||||
|
||||
# Plain text email - this could be replaced for a HTML-based email in the future
|
||||
email_body_base = str("")
|
||||
email_body_base += "Dear Voter,\n\n"
|
||||
email_body_base += "Thank you for your vote(s) for the event: " + eventTitle + ". This has been securely encrypted "
|
||||
email_body_base += "and anonymously stored in our system.\n\n"
|
||||
email_body_base += "For your reference, the identifier for your selected ballot is:\n"
|
||||
email_body_base += ballotHandle
|
||||
email_body_base += get_email_sign_off()
|
||||
|
||||
voter.send_email(email_subject, email_body_base)
|
||||
|
||||
|
||||
'''
|
||||
Updates the EID of an event to contain 2 event IDs: a human readable one (hr) and a crypto one (GP from param())
|
||||
'''
|
||||
|
|
|
@ -18,6 +18,7 @@ from allauthdemo.auth.models import DemoUser
|
|||
|
||||
from .tasks import email_trustees_prep, update_EID, generate_combpk, event_ended, create_ballots
|
||||
from .tasks import create_ballots_for_poll, email_voters_vote_url, combine_decryptions_and_tally, combine_encrypted_votes
|
||||
from .tasks import email_voting_success
|
||||
|
||||
from .utils.EventModelAdaptor import EventModelAdaptor
|
||||
|
||||
|
@ -220,7 +221,9 @@ def event_vote(request, event_id, poll_id):
|
|||
ballot.selection = selection
|
||||
ballot.save()
|
||||
|
||||
combine_encrypted_votes.delay(email_key[0].user, poll)
|
||||
voter = email_key[0].user
|
||||
combine_encrypted_votes.delay(voter, poll)
|
||||
email_voting_success.delay(voter, handle_json, event.title)
|
||||
|
||||
if next_poll_uuid:
|
||||
return HttpResponseRedirect(reverse('polls:event-vote', kwargs={'event_id': event.uuid,
|
||||
|
|
Reference in a new issue