Esempio n. 1
0
def compose_and_send_adg_password_reset_email(user, request):
    """
    Prepare and send email for password reset

    Arguments:
        user (User): Django user object
        request (Request): Request Object

    Returns:
        None
    """
    reset_link = '{protocol}://{site}{link}?track=pwreset'.format(
        protocol='https' if request.is_secure() else 'http',
        site=configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME),
        link=reverse('password_reset_confirm',
                     kwargs={
                         'uidb36': int_to_base36(user.id),
                         'token': default_token_generator.make_token(user),
                     }),
    )

    context = {
        'first_name': get_user_first_name(user),
        'reset_link': reset_link
    }

    task_send_mandrill_email(MandrillClient.PASSWORD_RESET, [user.email],
                             context)
Esempio n. 2
0
def compose_and_send_adg_update_email_confirmation(user, context):
    """
    Prepare and send email for change email confirmation

    Arguments:
        user (User): Django user object
        context (dict): Dictionary containing email content

    Returns:
        None
    """
    task_send_mandrill_email(MandrillClient.VERIFY_CHANGE_USER_EMAIL,
                             [user.email], context)
Esempio n. 3
0
def send_adg_password_reset_success_email(user, request):
    """
    Sends edx default email if the environment is testing. Otherwise, sends adg password reset
    success email
    """
    from openedx.core.djangoapps.user_authn.views.password_reset import send_password_reset_success_email

    if is_testing_environment():
        send_password_reset_success_email(user, request)
        return

    root_url = configuration_helpers.get_value('LMS_ROOT_URL',
                                               settings.LMS_ROOT_URL)
    context = {
        'first_name': get_user_first_name(user),
        'signin_link': '{}/login'.format(root_url),
    }

    task_send_mandrill_email(MandrillClient.PASSWORD_RESET_SUCCESS,
                             [user.email], context)
Esempio n. 4
0
def compose_and_send_adg_activation_email(user, activation_key):
    """
    Prepare and send email for account activation

    Arguments:
        user (User): Django user object
        activation_key (str): Activation key that will be sent as email content

    Returns:
        None
    """
    root_url = configuration_helpers.get_value('LMS_ROOT_URL',
                                               settings.LMS_ROOT_URL)
    activation_url = '{root_url}/activate/{activation_key}'.format(
        root_url=root_url, activation_key=activation_key)

    context = {
        'first_name': get_user_first_name(user),
        'activation_link': activation_url
    }

    task_send_mandrill_email(MandrillClient.USER_ACCOUNT_ACTIVATION,
                             [user.email], context)
Esempio n. 5
0
def test_task_send_mandrill_email(mock_mandrill_client, email_addresses):
    task_send_mandrill_email('email_template', email_addresses,
                             {'content': 'content'})
    mock_mandrill_client.assert_called_once()