def perform_mutate(cls, form, info: ResolveInfo): request = info.context scf = get_scaffolding(request) city = scf.city state = scf.state if not (city and state): return cls.make_error( "You haven't provided your city and state yet!") cleaned_data, is_valid = cls.validate_address(form.cleaned_data, city=city, state=state) if not is_zip_code_valid_for_state(cleaned_data["zip_code"], state): return cls.make_error( _("Please enter a valid ZIP code for %(state_name)s.") % {"state_name": US_STATE_CHOICES.get_label(state)}, field="zip_code", ) if is_valid and is_lnglat_in_nyc(cleaned_data["lnglat"]): return cls.make_error( _("Your address appears to be within New York City. Please " 'go back and enter "New York City" as your city.'), code="ADDRESS_IS_IN_NYC", ) update_scaffolding(request, cleaned_data) return cls.mutation_success(is_valid=is_valid)
def __extract_all_step_session_data( cls, request: HttpRequest) -> Optional[Dict[str, Any]]: scf = get_scaffolding(request) if not (scf.first_name and scf.last_name and scf.street and scf.lease_type and scf.receives_public_assistance is not None): return None return with_keys_renamed( scf.dict(), forms.OnboardingStep1V2Form.from_scaffolding_keys)
def perform_mutate(cls, form, info: ResolveInfo): request = info.context result = super().perform_mutate(form, info) scf = get_scaffolding(request) assert scf.street and scf.borough full_address = scf.street + ", " + scf.borough bbl, _, _ = lookup_bbl_and_bin_and_full_address(full_address) request.session[ RENT_STAB_INFO_SESSION_KEY] = get_rent_stab_info_for_bbl(bbl) return result
def test_onboarding_step_1_works(graphql_client): ob = _exec_onboarding_step_n("1V2", graphql_client) assert ob["errors"] == [] scf = get_scaffolding(graphql_client.request) assert scf.first_name == "boop" assert scf.last_name == "jones" assert scf.apt_number == "3B" assert scf.street == "123 boop way" assert scf.borough == "MANHATTAN" assert scf.preferred_first_name == "bip" assert _get_step_1_info(graphql_client)["aptNumber"] == "3B" assert _get_step_1_info(graphql_client)["addressVerified"] is False assert SCAFFOLDING_SESSION_KEY in graphql_client.request.session
def perform_mutate(cls, form, info): request = info.context scf = get_scaffolding(request) if not scaffolding_has_rental_history_request_info(scf): cls.log( info, "User has not completed the rental history form, aborting mutation." ) return cls.make_error( "You haven't completed all the previous steps yet.") rhr = models.RentalHistoryRequest( first_name=scf.first_name, last_name=scf.last_name, apartment_number=scf.apt_number, phone_number=scf.phone_number, address=scf.street, address_verified=scf.address_verified, borough=scf.borough, zipcode=scf.zip_code, ) rhr.set_user(request.user) rhr.full_clean() rhr.save() slack.sendmsg_async(get_slack_notify_text(rhr), is_safe=True) email = react_render_email( SITE_CHOICES.JUSTFIX, project.locales.DEFAULT, "rh/email-to-dhcr.txt", session=request.session, ) email_dhcr.send_email_to_dhcr(email.subject, email.body) trigger_followup_campaign_async( f"{scf.first_name} {scf.last_name}", scf.phone_number, "RH", locale=translation.get_language_from_request(request, check_path=True), ) # Note that we used to purge the scaffolding information here, but lots # of users go on to create an account after this, and we don't want them # to have to re-enter all their information, so we'll keep it around. return cls.mutation_success()
def get_previous_step_info(cls, request) -> Optional[Dict[str, Any]]: scf = get_scaffolding(request) phone_number = get_last_queried_phone_number(request) if cls.require_email and not scf.email: return None if not are_all_truthy(phone_number, scf.first_name, scf.last_name, scf.city, scf.state): return None assert cls.signup_intent, "signup_intent must be set on class!" info: Dict[str, Any] = { "phone_number": phone_number, "first_name": scf.first_name, "last_name": scf.last_name, "preferred_first_name": scf.preferred_first_name, "state": scf.state, "email": scf.email, "signup_intent": cls.signup_intent, "can_receive_rttc_comms": scf.can_receive_rttc_comms, "can_receive_saje_comms": scf.can_receive_saje_comms, } return cls.fill_city_info(request, info, scf)