Exemplo n.º 1
0
 def test_get_by_block(self):
     election_codes = ['102000638','102000648','102000665','31000053']
     block = {
         'precinct_id': 3703,
         'street_name': 'BRUCE',
         'street_type': 'ST',
         'low_addr': '',
         'high_addr': '',
         'odd_even': ''
     }
     voters = Voter.get_by_block(block, election_codes)
     block = {
         'precinct_id': 3703,
         'street_name': 'BRUCE',
         'street_type': 'ST',
         'low_addr': '1001',
         'high_addr': '1033',
         'odd_even': ''
     }
     voters = Voter.get_by_block(block, election_codes)
     block = {
         'precinct_id': 3703,
         'street_name': 'BRUCE',
         'street_type': 'ST',
         'low_addr': '1001',
         'high_addr': '1033',
         'odd_even': 'O',
     }
     voters = Voter.get_by_block(block, election_codes)
     pass
Exemplo n.º 2
0
def worksheet():
    from models.address import Address
    from models.election import Election

    if request.method == 'GET':
        dao = Dao()
        jurisdictions = Turf.get_jurisdictions(dao)
        return render_template('voters/worksheet.html',
                               title='Voter Worksheet',
                               jurisdictions=jurisdictions)

    blocks = json.loads(request.form['params'])['blocks']
    dao = Dao(stateful=True)
    elections = Election.get(dao)

    data = []

    for block in blocks:
        data += Voter.get_by_block(dao, block, elections)
    voters = []

    dao.close()

    for voter in data:
        v = [
            voter['last_name'], voter['first_name'], voter['middle_name'],
            voter['name_suffix'],
            str(Address(voter)), voter['city'], voter['zipcode'],
            voter['gender'],
            str(voter['birth_year']),
            voter['party'] if voter['party'] else 'N', voter['voter_id'],
            voter['reg_date'], voter['permanent_absentee']
            if voter['permanent_absentee'] else 'N', voter['status'],
            voter['uocava']
        ]
        for election in elections:
            v.append(voter[election['date']])
        voters.append(v)

    return jsonify(elections=[
        election['date'] + ":" + election['description']
        for election in elections
    ],
                   voters=voters)