Пример #1
0
 def get_sms_text(self, user):
     url = absolutify_url("/")
     return (
         f"Hey {user.best_first_name}! "
         f"Don't forget that you can use {get_site_name()} to address "
         f"repair issues in your apartment. "
         f"Follow this link to continue: {url}"
     )
Пример #2
0
def remind_user_about_loc(user):
    url = absolutify_url('/')
    sid = user.send_sms(
        f'Hey {user.first_name}! '
        f'Don\'t forget that you can use {get_site_name()} to address '
        f'repair issues in your apartment. '
        f'Follow this link to continue: {url}')
    if sid:
        Reminder(kind=REMINDERS.LOC,
                 sent_at=timezone.now(),
                 user=user,
                 sid=sid).save()
Пример #3
0
def send_admin_notification_for_letter(letter_id: int):
    from django.template.loader import render_to_string
    from django.core.mail import EmailMessage
    from django.conf import settings

    from project.util.site_util import absolute_reverse
    from .models import LetterRequest, LOC_MAILING_CHOICES

    letter = LetterRequest.objects.get(id=letter_id)
    user = letter.user

    assert letter.mail_choice == LOC_MAILING_CHOICES.WE_WILL_MAIL

    body = render_to_string(
        "loc/admin/notification-email.txt",
        {
            "user":
            user,
            "letter":
            letter,
            "send_letter_url":
            absolute_reverse("admin:mail-via-lob",
                             kwargs={"letterid": letter.id}),
            "reject_letter_url":
            absolute_reverse("admin:reject-letter",
                             kwargs={"letterid": letter.id}),
            "archive_letter_url":
            absolute_reverse("admin:archive-letter",
                             kwargs={"letterid": letter.id}),
            "user_loc_url":
            absolutify_url("/loc/issues"),
            "edit_letter_url":
            absolute_reverse("admin:loc_locuser_change", args=(user.pk, )),
        },
    )
    subject = f"Letter of Complaint request for {user.full_legal_name}"
    user_email = user.as_email_recipient()

    msg = EmailMessage(
        subject=subject,
        body=body,
        from_email=settings.DEFAULT_FROM_EMAIL,
        to=[settings.LOC_EMAIL],
        reply_to=[user_email] if user_email else None,
    )
    msg.send()
Пример #4
0
    def perform_mutate(cls, form, info: ResolveInfo):
        request = info.context
        user = request.user
        if not user.email:
            return cls.make_error("You have no email address!")

        if not user.is_email_verified:
            return cls.make_error("Your email address is not verified!")

        docs = HPActionDocuments.objects.get_latest_for_user(
            user, HP_ACTION_CHOICES.EMERGENCY)

        if not docs:
            return cls.make_error("You have no HP Action documents to sign!")

        api_client = docusign.core.create_default_api_client()
        de = DocusignEnvelope.objects.filter(docs=docs).first()

        if de is None:
            envelope_definition = hpadocusign.create_envelope_definition_for_hpa(
                docs)
            envelope_id = hpadocusign.create_envelope_for_hpa(
                envelope_definition=envelope_definition, api_client=api_client)
            slack.sendmsg_async(
                f"{slack.hyperlink(text=user.best_first_name, href=user.admin_url)} "
                f"has started the Emergency HP Action signing ceremony! 🔥",
                is_safe=True,
            )
            de = DocusignEnvelope(id=envelope_id, docs=docs)
            de.save()

        return_url = hpadocusign.create_callback_url_for_signing_flow(
            request,
            envelope_id=de.id,
            next_url=absolutify_url(form.cleaned_data["next_url"]),
        )

        url = hpadocusign.create_recipient_view_for_hpa(
            user=user,
            envelope_id=de.id,
            api_client=api_client,
            return_url=return_url,
        )

        return cls(errors=[], redirect_url=url)
Пример #5
0
    def get_sms_text(self, user):
        norentSite = site_util.get_site_of_type(site_util.SITE_CHOICES.NORENT)
        norentUrl = site_util.absolutify_url("/", site=norentSite)
        housingIsKeyUrl = "https://housing.ca.gov/"
        if self.year_and_month == "2021-02":
            msg = _(
                "%(first_name)s, you've previously created an account on NoRent.org. "
                "The California Tenant Relief Act of 2020 was extended by the new law SB91. "
                "In order to be protected from eviction, you must send a new declaration "
                "letter to your landlord through NoRent.org: %(norentUrl)s")
        elif self.year_and_month == "2021-07":
            msg = _(
                "%(first_name)s, you've previously created an account on NoRent.org. "
                "The California Tenant Relief Act of 2020 was extended by the new law AB832. "
                "In order to be protected from eviction, you must send a new declaration "
                "letter to your landlord through NoRent.org: %(norentUrl)s")
        elif self.year_and_month == "2021-10":
            msg = _(
                "This is NoRent, texting from a new number. You’ve previously created an account "
                "on NoRent.org. On Friday, Oct 1, 2021, California’s statewide protections "
                "for tenants unable to pay rent due to COVID-19 (AB832) expired. If "
                "you have not submitted a declaration for a month you were unable to pay rent, "
                "do so now through NoRent.org: %(norentUrl)s. We also strongly encourage you to "
                "apply for government rental assistance through Housing is Key: "
                "%(housingIsKeyUrl)s or call 833-430-2122.")
        else:
            msg = _(
                "%(first_name)s, you've previously created an account on NoRent.org. "
                "If you are unable to pay rent next month AND you have a COVID-19 "
                "related reason for not paying, we recommend that on or before your "
                "rent due date or within 7 days of your rent due date, you send a "
                "new AB832 declaration to your landlord through NoRent.org: %(norentUrl)s"
            )

        params = {
            "first_name": user.best_first_name,
            "norentUrl": norentUrl,
            "housingIsKeyUrl": housingIsKeyUrl,
        }

        return msg % params
Пример #6
0
def get_site_hyperlink() -> str:
    return hyperlink(text=Site.objects.get_current().name,
                     href=absolutify_url('/'))
Пример #7
0
def get_site_hyperlink() -> str:
    return hyperlink(text=get_default_site().name, href=absolutify_url("/"))