def email_trustees_2(self, election, body): user, api_client, election = self.check(election, True) # the message to email message = """ %s Your Trustee homepage for election "%s" is: %s Your password is: %s -- The Helios Voting System """ subject = "Trustee Information for %s" % election.name trustees = election.get_keyshares() for trustee in trustees: full_body = message % (body, election.name, config.webroot + ('/elections/%s/trustees/%s/home' % (election.election_id, utils.urlencode(trustee.email))), trustee.password) # send out the emails for the shares mail.simple_send([trustee.email],[trustee.email],"Helios","*****@*****.**", subject, full_body) return "DONE"
def email_trustees_2(self, election, body): user, api_client, election = self.check(election, True) # the message to email message = """ %s Your Trustee homepage for election "%s" is: %s Your password is: %s -- The Helios Voting System """ subject = "Trustee Information for %s" % election.name trustees = election.get_keyshares() for trustee in trustees: full_body = message % ( body, election.name, config.webroot + ('/elections/%s/trustees/%s/home' % (election.election_id, utils.urlencode(trustee.email))), trustee.password) # send out the emails for the shares mail.simple_send([trustee.email], [trustee.email], "Helios", "*****@*****.**", subject, full_body) return "DONE"
def submit(self, voter, email, password, encrypted_vote): """ A voter submits her encrypted vote. """ election = self.parent election_obj = election.toElection() # if election has results already if election.result_json: raise cherrypy.HTTPError(500, "Tally Already Computed") # password check if not voter.password == password: raise cherrypy.HTTPError(403, "Bad Password") # set in DB voter.set_encrypted_vote(encrypted_vote) # send a confirmation email mail_body = """ Dear %s, Your vote in election "%s" was recorded. For your verification, we include below the fingerprint of your encrypted vote: %s And, as a reminder, the fingerprint of the election itself is: %s -- The Helios Voting System """ % (voter.name, election_obj.name, voter.get_vote_hash(), election_obj.hash) mail.simple_send([voter.name], [voter.email], "Helios", "*****@*****.**", "your vote was recorded", mail_body) return SUCCESS
def submit(self, voter, email, password, encrypted_vote): """ A voter submits her encrypted vote. """ election = self.parent election_obj = election.toElection() # if election has results already if election.result_json: raise cherrypy.HTTPError(500, "Tally Already Computed") # password check if not voter.password == password: raise cherrypy.HTTPError(403, "Bad Password") # set in DB voter.set_encrypted_vote(encrypted_vote) # send a confirmation email mail_body = """ Dear %s, Your vote in election "%s" was recorded. For your verification, we include below the fingerprint of your encrypted vote: %s And, as a reminder, the fingerprint of the election itself is: %s -- The Helios Voting System """ % (voter.name, election_obj.name, voter.get_vote_hash(), election_obj.hash) mail.simple_send([voter.name],[voter.email], "Helios", "*****@*****.**", "your vote was recorded", mail_body) return SUCCESS
def voters_email_2(self, election, introductory_message, voter_ids=None, after=None, limit=None): """ Send email to voters of an election. """ user, api_client, election = self.check(election, True, True) if after: after = str(after) if limit: limit = int(limit) if voter_ids: raw_voter_id_list = voter_ids.split(",") voter_id_list = [] if after: # adjust the list given the value of "after" copy_p = False else: copy_p = True # mimicking after and limit for v_id in raw_voter_id_list: if copy_p: voter_id_list.append(v_id) if (not copy_p) and (v_id == after): copy_p = True if len(voter_id_list) >= limit: break voters = [do.Voter.selectById(voter_id) for voter_id in voter_id_list] for voter in voters: if election.election_id != voter.election.election_id: self.error('bad voter') else: voters = election.get_voters(after=after, limit=limit) last_id = None # send as the owner of the election if user: sender_email = user.email_address else: sender_email = "*****@*****.**" for voter in voters: logging.info("sending email to %s" % voter.email) message_header = u""" Dear %s, """ % voter.name message_footer = u""" Election URL: %s Direct Voting URL: %s Election Fingerprint: %s Your email address: %s Your password: %s -- %s via the Helios Voting System www.heliosvoting.org """ % ((config.webroot + '/elections/%s/view')%election.election_id, (config.webroot + '/elections/%s/vote')%election.election_id, election.toElection().get_hash(), voter.email, voter.password, sender_email) message = message_header logging.info(introductory_message) message += unicode(introductory_message) message += message_footer mail.simple_send([voter.name], [voter.email], "Helios", sender_email,"Voting in Election %s" % election.name, message) last_id = voter.voter_id # did we get less than the limit? if so, done if limit and len(voters) < limit: last_id = None # hack for now, no more batching return last_id or "DONE"
def voters_email_2(self, election, introductory_message, voter_ids=None, after=None, limit=None): """ Send email to voters of an election. """ user, api_client, election = self.check(election, True, True) if after: after = str(after) if limit: limit = int(limit) if voter_ids: raw_voter_id_list = voter_ids.split(",") voter_id_list = [] if after: # adjust the list given the value of "after" copy_p = False else: copy_p = True # mimicking after and limit for v_id in raw_voter_id_list: if copy_p: voter_id_list.append(v_id) if (not copy_p) and (v_id == after): copy_p = True if len(voter_id_list) >= limit: break voters = [ do.Voter.selectById(voter_id) for voter_id in voter_id_list ] for voter in voters: if election.election_id != voter.election.election_id: self.error('bad voter') else: voters = election.get_voters(after=after, limit=limit) last_id = None # send as the owner of the election if user: sender_email = user.email_address else: sender_email = "*****@*****.**" for voter in voters: logging.info("sending email to %s" % voter.email) message_header = u""" Dear %s, """ % voter.name message_footer = u""" Election URL: %s Direct Voting URL: %s Election Fingerprint: %s Your email address: %s Your password: %s -- %s via the Helios Voting System www.heliosvoting.org """ % ((config.webroot + '/elections/%s/view') % election.election_id, (config.webroot + '/elections/%s/vote') % election.election_id, election.toElection().get_hash(), voter.email, voter.password, sender_email) message = message_header logging.info(introductory_message) message += unicode(introductory_message) message += message_footer mail.simple_send([voter.name], [voter.email], "Helios", sender_email, "Voting in Election %s" % election.name, message) last_id = voter.voter_id # did we get less than the limit? if so, done if limit and len(voters) < limit: last_id = None # hack for now, no more batching return last_id or "DONE"