def getElection(pk): queryset = Election.get_by_uuid(pk) if (queryset): return queryset queryset = Election.get_by_short_name(pk) if (queryset): return queryset raise_exception(404, 'Election not Found.')
def get_election_by_uuid(uuid): if not uuid: raise Exception("no election ID") return Election.get_by_uuid(uuid)
def get_cast_vote(election_pk, voter_pk): '''Get cast vote by election and voter keys.''' election = Election.get_by_uuid(election_pk) voter = Voter.get_by_election_and_uuid(election, voter_pk) return CastVote.get_by_voter(voter)