def index(request): """Get user email + zip and validate against AN.""" args = {} args['form'] = intake_forms.IntakeForm() if request.method == 'POST': form = intake_forms.IntakeForm(request.POST) if form.is_valid(): email_address, zip_code = (form.cleaned_data.get('email_address'), form.cleaned_data.get('zip_code')) data = API.get_person(search_string=email_address) logger.debug(data) person = osdi_to_person(data) logger.debug(data) event_person = create_person_model(data=person, email_address=email_address, zip_code=zip_code) return HttpResponseRedirect( reverse('intake:confirm', kwargs={'pk': event_person.id})) else: args['form'] = intake_forms.IntakeForm(request.POST) return render(request, 'intake/index.html', args) else: return render(request, 'intake/index.html', args)
def test_create_person_with_bad_address(self): data = osdi_to_person(SAMPLE_PERSON_DATA5) person = create_person_model(data=data, email_address='*****@*****.**', zip_code='19143') assert person.email_address == '*****@*****.**' assert person.zip_code == '19143' assert person.id is not None assert person.city is ''
def test_create_person_with_data(self): data = osdi_to_person(SAMPLE_PERSON_DATA1) person = create_person_model(data=data, email_address='*****@*****.**', zip_code='19143') assert person.email_address == '*****@*****.**' assert person.first_name == 'Test' assert person.last_name == 'User' assert person.phone_number == '555-001-0022', person.phone_number assert person.action_network_id == 'asdfasdf-asdfasdf-asdfasdf' assert person.street_address_one == '10001 Test Ave' assert not person.street_address_two assert person.city == 'Philadelphia' assert person.state == 'PA' assert str(person) == '*****@*****.**'
def test_create_person_without_data(self): person = create_person_model(email_address='*****@*****.**', zip_code='19143') assert person.email_address == '*****@*****.**' assert person.zip_code == '19143' assert person.id is not None
def test_create_person_with_no_action_network_id(self): data = osdi_to_person(SAMPLE_PERSON_DATA4) person = create_person_model(data=data, email_address='*****@*****.**', zip_code='19143') assert not person.street_address_two
def test_create_person_with_two_line_address(self): data = osdi_to_person(SAMPLE_PERSON_DATA2) person = create_person_model(data=data, email_address='*****@*****.**', zip_code='19143') assert person.street_address_two == 'Apt 2'
def setUp(self): self.client = Client() self.person = create_person_model(email_address='*****@*****.**', zip_code='19143')