Exemplo n.º 1
0
def get_precincts():
    dao = Dao()
    if 'ward_no' in request.args:
        precincts = Turf.get_precincts(dao, request.args['jurisdiction_code'],
                                       request.args['ward_no'])
    else:
        precincts = Turf.get_precincts(dao, request.args['jurisdiction_code'])
    return jsonify(precincts=precincts)
Exemplo n.º 2
0
def get_house_nums():
    dao = Dao()
    nums = Turf.get_house_nums(dao, request.args['county_code'],
                               request.args['jurisdiction_code'],
                               request.args['street_name'],
                               request.args['street_type'])
    return jsonify(house_nums=nums)
Exemplo n.º 3
0
def csv_export():
    from models.turf import Turf

    dao = Dao()
    jurisdictions = Turf.get_jurisdictions(dao)
    return render_template('contacts/con_export.html',
                           title='Contact Export',
                           jurisdictions=jurisdictions)
Exemplo n.º 4
0
def name_duplicates():
    if request.method == 'GET':
        dao = Dao(stateful=True)
        cities = Turf.get_city_names(dao)
        dups = Contact.get_name_dups(dao)
        dao.close()
        for dup in dups:
            dup['name'] = str(PersonName(dup))
            dup['address'] = str(Address(dup))

        return render_template('contacts/con_dups.html',
                               title='Name Duplicates',
                               dups=dups,
                               cities=cities)
Exemplo n.º 5
0
def csv_import():
    from models.turf import Turf
    from models.submission import Submission

    if request.method == 'GET':
        return render_template('voters/voter_import.html',
                               title='Voter Import')

    data = json.loads(request.form['params'])['data']
    cities = Turf.get_cities()
    submissions = [
        Submission.from_web(rec, cities) for rec in data if rec['data0']
    ]
    Voter.batch_lookup(submissions)
    return jsonify(
        lookups=[submission.serialize() for submission in submissions])
Exemplo n.º 6
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)
Exemplo n.º 7
0
 def get_data(self):
     return Turf.get_precincts(self.dao)
Exemplo n.º 8
0
 def get_data(self):
     return Turf.get_jurisdictions(self.dao)
Exemplo n.º 9
0
def get_streets():
    dao = Dao()
    streets = Turf.get_streets(dao, request.args['jurisdiction_code'],
                               request.args['ward'], request.args['precinct'])
    return jsonify(streets=streets)
Exemplo n.º 10
0
def get_wards():
    dao = Dao()
    wards = Turf.get_wards(dao, request.args['jurisdiction_code'])
    return jsonify(wards=wards)