def run_test(): cities = Address.get_cities() f = open('voter_test.csv', 'r') rdr = csv.reader(f) submissions = [Submission.from_csv(row, cities, with_contact=False) for row in rdr] lookups = Voter.lookup(submissions) for lookup in lookups: print(str(lookup.name), str(lookup.address)) for match in lookup.matches: print(str(match), str(match.address)) print('\n')
def run_test(): cities = Address.get_cities() f = open('voter_test.csv', 'r') rdr = csv.reader(f) submissions = [ Submission.from_csv(row, cities, with_contact=False) for row in rdr ] lookups = Voter.lookup(submissions) for lookup in lookups: print(str(lookup.name), str(lookup.address)) for match in lookup.matches: print(str(match), str(match.address)) print('\n')
def lookup(): dao = Dao() matches = Voter.lookup(dao, request.args) result = [{ 'name': str(match.name), 'address': str(match.address), 'city': match.address.city, 'zipcode': match.address.zipcode, 'gender': match.gender, 'birth_year': match.birth_year, 'voter_id': match.id } for match in matches] return jsonify(matches=result)
def voter_lookup(): from models.voter import Voter contact = json.loads(request.form['params']) dao = Dao(stateful=True) try: voters = Voter.lookup(dao, contact) candidates = [{ 'name': { 'last': voter.name.last, 'first': voter.name.first, 'middle': voter.name.middle, 'suffix': voter.name.suffix }, 'address': { 'house_number': voter.address.house_number, 'pre_direction': voter.address.pre_direction, 'street_name': voter.address.street_name, 'street_type': voter.address.street_type, 'suf_direction': voter.address.suf_direction, 'unit': voter.address.unit, 'city': voter.address.city, 'zipcode': voter.address.zipcode }, 'voter_info': { 'voter_id': voter.voter_id, 'precinct_id': voter.precinct_id, 'birth_year': voter.birth_year, 'gender': voter.gender, 'reg_date': voter.reg_date } } for voter in voters] return jsonify(candidates=candidates) except Exception as ex: return jsonify(error=str(ex)) finally: dao.close()