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)
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)
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)
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)
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])
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)
def get_data(self): return Turf.get_precincts(self.dao)
def get_data(self): return Turf.get_jurisdictions(self.dao)
def get_streets(): dao = Dao() streets = Turf.get_streets(dao, request.args['jurisdiction_code'], request.args['ward'], request.args['precinct']) return jsonify(streets=streets)
def get_wards(): dao = Dao() wards = Turf.get_wards(dao, request.args['jurisdiction_code']) return jsonify(wards=wards)