Exemple #1
0
def send_email_verification(email: "EmailAddress"):
    """
    Verify the given `EmailAddress`.
    """
    verification_url = reverse('email-verification:verify',
                               kwargs={
                                   'code': email.key,
                               })
    html_email_helper(
        template_base_name=EMAIL_VERIFICATION_TEMPLATE,
        context={'verification_url': get_site_url(verification_url)},
        subject=EMAIL_VERIFICATION_SUBJECT,
        recipient_list=(email.email, ),
        from_email=EMAIL_VERIFICATION_SENDER,
    )
Exemple #2
0
def send_dns_not_configured_email(application: BetaTestApplication) -> None:
    """
    Send an email with DNS configuration details to the user after detecting
    that the DNS is not configured properly
    """
    user = application.user
    context = dict(cname_value=settings.EXTERNAL_DOMAIN_CNAME_VALUE,
                   external_domain=application.external_domain)
    logger.info(
        "Sending email to %s for DNS Configuration for external domain",
        user.email)
    html_email_helper(template_base_name='emails/dns_not_configured',
                      context=context,
                      subject="OpenCraft domain verification failed!",
                      recipient_list=(user.email, ))
Exemple #3
0
def send_welcome_email(application: BetaTestApplication) -> None:
    """
    Send a welcome email to a new user after they have confirmed their email
    addresses.
    """
    user = application.user
    context = dict(
        user_name=user.profile.full_name,
        lms_link=application.instance.get_domain('lms'),
        studio_link=application.instance.get_domain('studio'),
        customise_link=settings.USER_CONSOLE_FRONTEND_URL,
    )
    html_email_helper(template_base_name='emails/welcome_email',
                      context=context,
                      subject=settings.WELCOME_EMAIL_SUBJECT,
                      recipient_list=(user.email, ))
Exemple #4
0
def send_email_verification(email: "EmailAddress"):
    """
    Verify the given `EmailAddress`.

    The verification link points to the frontend, which then
    uses the Email verification viewset to make a request to
    the backend and activate the email.
    """
    verification_url = urljoin(settings.USER_CONSOLE_FRONTEND_URL,
                               f"/verify-email/{email.key}/")
    html_email_helper(
        template_base_name=EMAIL_VERIFICATION_TEMPLATE,
        context={'verification_url': verification_url},
        subject=EMAIL_VERIFICATION_SUBJECT,
        recipient_list=(email.email, ),
        from_email=EMAIL_VERIFICATION_SENDER,
    )
Exemple #5
0
def send_account_info_email(application: BetaTestApplication) -> None:
    """
    Send an email with account information to a new user after they have
    confirmed their email addresses and their instance is set up.
    """
    user = application.user
    context = dict(
        user_name=user.profile.full_name,
        instance_url=application.instance.get_domain('lms'),
        instance_name=application.instance_name,
        full_name=user.profile.full_name,
        email=user.email,
        public_contact_email=application.public_contact_email,
    )
    html_email_helper(template_base_name='emails/account_info_email',
                      context=context,
                      subject=settings.ACCOUNT_INFO_EMAIL_SUBJECT,
                      recipient_list=(user.email, ))
Exemple #6
0
def send_changes_deployed_success_email(
        application: BetaTestApplication) -> None:
    """
    Send an email to user after successful redeployment of the application.
    """
    instance_name = application.instance.name
    user = application.user
    context = dict(
        see_update_url=f"{settings.USER_CONSOLE_FRONTEND_URL}/console/notice")

    recipients = [user.email]

    logger.warning(
        "Sending notification e-mail to %s after instance %s was redeployed",
        recipients,
        instance_name,
    )

    html_email_helper(template_base_name='emails/redeployment_success_email',
                      context=context,
                      subject='Open edX instance deployment: Success',
                      recipient_list=recipients)
Exemple #7
0
def password_reset_token_created(
    sender: ResetPasswordRequestToken,
    instance: ResetPasswordRequestToken,
    reset_password_token: ResetPasswordToken,
    *_args,
    **_kwargs,
) -> None:
    """
    Handles password reset tokens.
    When a token is created, an e-mail is sent to the user

    :param sender: View Class that sent the signal
    :param instance: View Instance that sent the signal
    :param reset_password_token: Token Model Object
    """
    context = dict(
        reset_password_url=
        f"{settings.USER_CONSOLE_FRONTEND_URL}/password-reset/{reset_password_token.key}"
    )
    html_email_helper(template_base_name='emails/reset_password_email',
                      context=context,
                      subject=settings.RESET_PASSWORD_EMAIL_SUBJECT,
                      recipient_list=(reset_password_token.user.email, ))