<s> """<STR_LIT>""" <EOL> from celery . decorators import task <EOL> from models import * <EOL> from view_utils import render_template_raw <EOL> import signals <EOL> import copy <EOL> from django . conf import settings <EOL> @ task ( ) <EOL> def cast_vote_verify_and_store ( cast_vote_id , status_update_message = None , ** kwargs ) : <EOL> cast_vote = CastVote . objects . get ( id = cast_vote_id ) <EOL> result = cast_vote . verify_and_store ( ) <EOL> voter = cast_vote . voter <EOL> election = voter . election <EOL> user = voter . user <EOL> if result : <EOL> signals . vote_cast . send ( sender = election , election = election , user = user , voter = voter , cast_vote = cast_vote ) <EOL> if status_update_message and user . can_update_status ( ) : <EOL> from views import get_election_url <EOL> user . update_status ( status_update_message ) <EOL> else : <EOL> logger = cast_vote_verify_and_store . get_logger ( ** kwargs ) <EOL> logger . error ( "<STR_LIT>" % cast_vote_id ) <EOL> @ task ( ) <EOL> def voters_email ( election_id , subject_template , body_template , extra_vars = { } , <EOL> voter_constraints_include = None , voter_constraints_exclude = None ) : <EOL> """<STR_LIT>""" <EOL> election = Election . objects . get ( id = election_id ) <EOL> voters = election . voter_set . all ( ) <EOL> if voter_constraints_include : <EOL> voters = voters . filter ( ** voter_constraints_include ) <EOL> if voter_constraints_exclude : <EOL> voters = voters . exclude ( ** voter_constraints_exclude ) <EOL> for voter in voters : <EOL> single_voter_email . delay ( voter . uuid , subject_template , body_template , extra_vars ) <EOL> @ task ( ) <EOL> def voters_notify ( election_id , notification_template , extra_vars = { } ) : <EOL> election = Election . objects . get ( id = election_id ) <EOL> for voter in election . voter_set . all ( ) : <EOL> single_voter_notify . delay ( voter . uuid , notification_template , extra_vars ) <EOL> @ task ( ) <EOL> def single_voter_email ( voter_uuid , subject_template , body_template , extra_vars = { } ) : <EOL> voter = Voter . objects . get ( uuid = voter_uuid ) <EOL> the_vars = copy . copy ( extra_vars ) <EOL> the_vars . update ( { '<STR_LIT>' : voter } ) <EOL> subject = render_template_raw ( None , subject_template , the_vars ) <EOL> body = render_template_raw ( None , body_template , the_vars ) <EOL> voter . user . send_message ( subject , body ) <EOL> @ task ( ) <EOL> def single_voter_notify ( voter_uuid , notification_template , extra_vars = { } ) : <EOL> voter = Voter . objects . get ( uuid = voter_uuid ) <EOL> the_vars = copy . copy ( extra_vars ) <EOL> the_vars . update ( { '<STR_LIT>' : voter } ) <EOL> notification = render_template_raw ( None , notification_template , the_vars ) <EOL> voter . user . send_notification ( notification ) <EOL> @ task ( ) <EOL> def election_compute_tally ( election_id ) : <EOL> election = Election . objects . get ( id = election_id ) <EOL> election . compute_tally ( ) <EOL> election_notify_admin . delay ( election_id = election_id , <EOL> subject = "<STR_LIT>" , <EOL> body = """<STR_LIT>""" % election . name ) <EOL> if election . has_helios_trustee ( ) : <EOL> tally_helios_decrypt . delay ( election_id = election . id ) <EOL> @ task ( ) <EOL> def tally_helios_decrypt ( election_id ) : <EOL> election = Election . objects . get ( id = election_id ) <EOL> election . helios_trustee_decrypt ( ) <EOL> election_notify_admin . delay ( election_id = election_id , <EOL> subject = '<STR_LIT>' , <EOL> body = """<STR_LIT>""" % election . name ) <EOL> @ task ( ) <EOL> def voter_file_process ( voter_file_id ) : <EOL> voter_file = VoterFile . objects . get ( id = voter_file_id ) <EOL> voter_file . process ( ) <EOL> election_notify_admin . delay ( election_id = voter_file . election . id , <EOL> subject = '<STR_LIT>' , <EOL> body = """<STR_LIT>""" % ( voter_file . election . name , voter_file . num_voters ) ) <EOL> @ task ( ) <EOL> def election_notify_admin ( election_id , subject , body ) : <EOL> election = Election . objects . get ( id = election_id ) <EOL> election . admin . send_message ( subject , body ) </s>
