예제 #1
0
def user_to_hpactionvars(user: JustfixUser, kind: str) -> hp.HPActionVariables:
    v = hp.HPActionVariables()

    # TODO: The HP Action form actually has a field for home phone
    # and a separate one for work; it's unclear which one the
    # user may have provided, but we'll assume it's home for now.
    v.tenant_phone_home_te = user.formatted_phone_number()

    v.tenant_name_first_te = user.first_name
    v.tenant_name_last_te = user.last_name

    # I'm not sure, but I *think* this is the "do you agree to the terms of use"
    # checkbox.
    v.flag_tf = True

    # The fact that there is a multiple-select option and
    # a set of booleans for the same thing is, I think, an
    # artifact of the history of the form; the original
    # version only had the multi-select, and a newer 2018
    # version introduced the booleans. I think only the
    # booleans are used, but I'm setting the multiple-select
    # too, just in case it's used anywhere.
    #
    # Note that in some cases, there are multiple-select
    # options *and* a set of booleans for the same thing.
    # Historically, there were originally just multiple-selects,
    # but later booleans were added, because A2J (one of the interview
    # formats) doesn't support multiple-select options, so the
    # hotdocs setup had to be modified to use a bunch of
    # booleans instead. In all cases, we only need to care
    # about the booleans, and can ignore the multiple-select
    # values.

    # We're only serving New Yorkers at the moment...
    v.tenant_address_state_mc = hp.TenantAddressStateMC.NEW_YORK

    fill_landlord_info(v, user)

    fill_if_user_has(fill_onboarding_info, v, user, "onboarding_info")

    fill_issues(v, user, kind)

    fill_tenant_children(v, TenantChild.objects.filter(user=user))

    fill_if_user_has_with_kind(fill_hp_action_details, v, user,
                               "hp_action_details", kind)

    if v.sue_for_harassment_tf:
        fill_if_user_has(fill_harassment_details, v, user,
                         "harassment_details")
        fill_prior_cases(v, user, kind)

    if kind != HP_ACTION_CHOICES.EMERGENCY:
        fill_if_user_has(fill_fee_waiver_details, v, user,
                         "fee_waiver_details")

    # Assume the tenant always wants to serve the papers themselves.
    v.tenant_wants_to_serve_tf = True

    return v
예제 #2
0
 def get_account_status_for_user(
         cls, request, user: JustfixUser) -> PhoneNumberAccountStatus:
     if user.has_usable_password():
         account_status = PhoneNumberAccountStatus.ACCOUNT_WITH_PASSWORD
     else:
         account_status = PhoneNumberAccountStatus.ACCOUNT_WITHOUT_PASSWORD
         password_reset.create_verification_code(request, user.phone_number)
     return account_status
예제 #3
0
def test_reads_and_writes_of_dwh_models_are_directed_to_dwh_db(settings):
    settings.DWH_DATABASE = 'boop'
    router = ReadAndWriteToDataWarehouseDb()
    run = RapidproRun()
    user = JustfixUser()
    assert router.db_for_read(run) == 'boop'
    assert router.db_for_read(user) is None
    assert router.db_for_write(run) == 'boop'
    assert router.db_for_write(user) is None
예제 #4
0
 def from_user(cls, user: JustfixUser) -> "EHPAAffadavitVars":
     oi = get_onboarding_info(user)
     v = HPActionVariables()
     fill_landlord_info(v, user)
     ld = get_landlord_details(user)
     return EHPAAffadavitVars(
         tenant_name=user.full_legal_name or NA,
         tenant_email=user.email or NA,
         tenant_phone=user.formatted_phone_number() or NA,
         tenant_address=", ".join(oi.address_lines_for_mailing) or NA,
         landlord_name=v.landlord_entity_name_te or NA,
         landlord_email=ld.email or NA,
         landlord_phone=ld.formatted_phone_number() or NA,
         landlord_address=get_landlord_address(v),
     )
예제 #5
0
 def perform_post_onboarding(cls, form, request: HttpRequest,
                             user: JustfixUser):
     user.send_sms_async(
         _("Welcome to %(site_name)s, a product by JustFix.nyc. "
           "We'll be sending you notifications from this phone number.") %
         {"site_name": site_util.get_site_name("NORENT")})
예제 #6
0
def test_docusign_client_user_id_works():
    user = JustfixUser(pk=5)
    assert core.docusign_client_user_id(user) == "5"
예제 #7
0
def user_to_hpactionvars(user: JustfixUser) -> hp.HPActionVariables:
    v = hp.HPActionVariables()

    # TODO: The HP Action form actually has a field for home phone
    # and a separate one for work; it's unclear which one the
    # user may have provided, but we'll assume it's home for now.
    v.tenant_phone_home_te = user.formatted_phone_number()

    v.tenant_name_first_te = user.first_name
    v.tenant_name_last_te = user.last_name

    # I'm not sure, but I *think* this is the "do you agree to the terms of use"
    # checkbox.
    v.flag_tf = True

    # The fact that there is a multiple-select option and
    # a set of booleans for the same thing is, I think, an
    # artifact of the history of the form; the original
    # version only had the multi-select, and a newer 2018
    # version introduced the booleans. I think only the
    # booleans are used, but I'm setting the multiple-select
    # too, just in case it's used anywhere.
    #
    # Note that in some cases, there are multiple-select
    # options *and* a set of booleans for the same thing.
    # Historically, there were originally just multiple-selects,
    # but later booleans were added, because A2J (one of the interview
    # formats) doesn't support multiple-select options, so the
    # hotdocs setup had to be modified to use a bunch of
    # booleans instead. In all cases, we only need to care
    # about the booleans, and can ignore the multiple-select
    # values.

    # We're only serving New Yorkers at the moment...
    v.tenant_address_state_mc = hp.TenantAddressStateMC.NEW_YORK

    fill_landlord_info(v, user)
    fill_nycha_info(v, user)

    if hasattr(user, 'onboarding_info'):
        oinfo = user.onboarding_info
        v.tenant_address_apt_no_te = oinfo.apt_number
        v.tenant_address_city_te = oinfo.city
        v.tenant_address_zip_te = oinfo.zipcode
        v.tenant_address_street_te = oinfo.address
        v.tenant_borough_mc = BOROUGHS[oinfo.borough]
        v.court_location_mc = COURT_LOCATIONS[oinfo.borough]
        v.court_county_mc = COURT_COUNTIES[oinfo.borough]

    for issue in user.issues.all():
        desc = ISSUE_CHOICES.get_label(issue.value)
        v.tenant_complaints_list.append(create_complaint(issue.area, desc))

    for cissue in user.custom_issues.all():
        v.tenant_complaints_list.append(
            create_complaint(cissue.area, cissue.description))

    fill_tenant_children(v, TenantChild.objects.filter(user=user))

    fill_if_user_has(fill_hp_action_details, v, user, 'hp_action_details')

    if v.sue_for_harassment_tf:
        fill_if_user_has(fill_harassment_details, v, user,
                         'harassment_details')
        fill_prior_cases(v, user)

    fill_if_user_has(fill_fee_waiver_details, v, user, 'fee_waiver_details')

    # Assume the tenant always wants to serve the papers themselves.
    v.tenant_wants_to_serve_tf = True

    return v
예제 #8
0
 def perform_post_onboarding(cls, form, request: HttpRequest,
                             user: JustfixUser):
     user.send_sms_async(
         f"Welcome to {site_util.get_site_name()}, {user.best_first_name}! "
         f"We'll be sending you notifications from this phone number.", )
     pass
예제 #9
0
 def test_it_sets_user_if_user_is_logged_in(self):
     rhr = RentalHistoryRequest()
     user = JustfixUser()
     rhr.set_user(user)
     assert rhr.user is user
예제 #10
0
 def test_it_works_with_many_recipients(self, db):
     user = JustfixUser(first_name="Boop", pk=1)
     assert get_slack_notify_text(user, "a peanut", 3) == (
         "<https://example.com/admin/users/justfixuser/1/change/|Boop> emailed "
         "a peanut to 3 recipients!")