Beispiel #1
0
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()
Beispiel #2
0
 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
Beispiel #3
0
 def test_get_block(self):
     dao = Dao(db_file='c:/bench/bluestreets/data/26161.db', stateful=True)
     contact = Contact()
     contact.address = Address({'address': '3000 Newcastle Rd'})
     contact.zipcode = '48105'
     block = Location.get_block(dao, contact)
     contact.zipcode = ''
     contact.city = 'ANN ARBOR'
     block = Location.get_block(dao, contact)
     dao.close()
 def test_get_block(self):
     dao = Dao(db_file='c:/bench/bluestreets/data/26161.db', stateful=True)
     contact = Contact()
     contact.address = Address({'address': '3000 Newcastle Rd'})
     contact.zipcode = '48105'
     block = Location.get_block(dao, contact)
     contact.zipcode = ''
     contact.city = 'ANN ARBOR'
     block = Location.get_block(dao, contact)
     dao.close()
 def test_get_best_turf(self):
     contact = Contact()
     contact.address = Address({
         'address': '3000 Newcastle Rd',
         'zipcode': '48105'
     })
     turf = Contact.get_best_turf(self.dao, contact)
     contact.address.zipcode = ''
     contact.address.city = 'ANN ARBOR'
     turf = Contact.get_best_turf(self.dao, contact)
     pass
 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
Beispiel #7
0
 def test_get_best_turf(self):
     contact = Contact()
     contact.address = Address({
         'address': '3000 Newcastle Rd',
         'zipcode': '48105'
     })
     turf = Contact.get_best_turf(self.dao, contact)
     contact.address.zipcode = ''
     contact.address.city = 'ANN ARBOR'
     turf = Contact.get_best_turf(self.dao, contact)
     pass
Beispiel #8
0
    def _get_fields_from_edit_(self):
        wd = self.app.wd
        contact = Contact()
        # GET main fields
        contact.id = self._get_field_value_(By.NAME, "id")
        contact.first_name = self._get_field_value_(By.NAME, "firstname")
        contact.middle_name = self._get_field_value_(By.NAME, "middlename")
        contact.last_name = self._get_field_value_(By.NAME, "lastname")
        contact.nickname = self._get_field_value_(By.NAME, "nickname")

        # GET companies fields
        contact.company = self._get_field_value_(By.NAME, "company")
        contact.title = self._get_field_value_(By.NAME, "title")
        contact.address = self._get_field_value_(By.NAME, "address")

        # GET phones fields
        contact.home_phone = self._get_field_value_(By.NAME, "home")
        contact.mobile_phone = self._get_field_value_(By.NAME, "mobile")
        contact.work_phone = self._get_field_value_(By.NAME, "work")
        contact.fax_phone = self._get_field_value_(By.NAME, "fax")

        # GET email fields
        contact.email = self._get_field_value_(By.NAME, "email")
        contact.email2 = self._get_field_value_(By.NAME, "email2")
        contact.email3 = self._get_field_value_(By.NAME, "email3")
        contact.homepage = self._get_field_value_(By.NAME, "homepage")

        # TODO do some stuff for get value of selector
        # GET birthday date field
        # if contact.birth_date is not date.min and contact.birth_date is not None:
        #     b_day = contact.birth_date.day.__str__()
        #     b_month = contact.birth_date.strftime("%B")
        #     b_year = contact.birth_date.year.__int__()
        # else:
        #     b_day = None
        #     b_month = None
        #     = None
        # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[1]", b_day)
        # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[2]", b_month)
        # b_year = self._get_field_value_(By.NAME, "byear", b_year)
        # contact.birth_date = date(b_year,b_month,b_day)

        # GET anniversary date field
        # if contact.anniversary_date is not date.min and contact.anniversary_date is not None:
        #     a_day = contact.anniversary_date.day.__str__()
        #     a_month = contact.anniversary_date.strftime("%B")
        #     a_year = contact.anniversary_date.year.__int__()
        # else:
        #     a_day = None
        #     a_month = None
        #     a_year = None
        # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[3]", a_day)
        # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[4]", a_month)
        # a_year = self._get_field_value_(By.NAME, "ayear")
        # contact.birth_date = date(a_year, a_month, a_day)

        # GET address fields
        contact.address2 = self._get_field_value_(By.NAME, "address2")
        contact.phone2 = self._get_field_value_(By.NAME, "phone2")
        contact.notes = self._get_field_value_(By.NAME, "notes")
        # Return founded fields
        return contact