def assign_precinct(): from models.precinct import Precinct if request.method == 'GET': precincts = Precinct.get_all() contacts = Contact.get_with_missing_precinct() return render_template('contacts/con_precinct.html', title='Unassigned Precinct', precincts=precincts, contacts=contacts) params = json.loads(request.form['params']) contact = Contact(params) dao = Dao(stateful=True) if 'voter_id' in params and params['voter_id']: voter = Voter.get_one(dao, params['voter_id']) nickname = contact.name.first contact.name = voter.name contact.name.nickname = nickname contact.address = voter.address contact.reg_date = voter.reg_date try: contact.update(dao) return jsonify(msg="Update successful!") except Exception as ex: return jsonify(error=str(ex)) finally: dao.close()
def test_get_best_voter(self): addr = Address({'address': '3000 Newcastle Rd'}) pn = PersonName({'last_name': 'weinblatt', 'first_name': 'howard'}) contact = Contact() contact.name = pn contact.address = addr voter = Contact.get_best_voter_rec(self.dao, contact) pass
def put(self, id=None): data = ApiContact.parser.parse_args() contact = Contact.find_by_id(data['id']) if contact is None: contact = Contact(data['name'], data['email']) else: contact.name = data['name'] contact.email = data['email'] contact.save_to_db() return contact.json()
def test_get_best_voter(self): addr = Address({'address': '3000 Newcastle Rd'}) pn = PersonName({ 'last_name': 'weinblatt', 'first_name': 'howard' }) contact = Contact() contact.name = pn contact.address = addr voter = Contact.get_best_voter_rec(self.dao, contact) pass