コード例 #1
0
def compose_and_send_adg_course_enrollment_invitation_email(
        user_email, message_context):
    """
    Prepare and send email for enrollment invitation by instructor

    Arguments:
        user_email (str): Email address of user
        message_context (dict): Dictionary containing email content

    Returns:
        None
    """
    if 'display_name' in message_context:
        message_context['course_name'] = message_context['display_name']
    elif 'course' in message_context:
        message_context['course_name'] = Text(
            message_context['course'].display_name_with_default)

    user = User.objects.filter(
        email=user_email).select_related('profile').first()
    if user:
        message_context['full_name'] = user.profile.name

    message_context.pop('course')
    task_send_mandrill_email.delay(MandrillClient.COURSE_ENROLLMENT_INVITATION,
                                   [user_email], message_context)
コード例 #2
0
def send_application_status_update_email(application, message_for_applicant):
    """
    Informs applicants about the decision taken against their application.

    Args:
        application (UserApplication): Application object
        message_for_applicant (str): Admin message for applicant

    Returns:
        None
    """
    UserApplication = apps.get_model('applications', 'UserApplication')

    status_email_template_map = {
        UserApplication.ACCEPTED: MandrillClient.APPLICATION_ACCEPTED,
        UserApplication.WAITLIST: MandrillClient.APPLICATION_WAITLISTED
    }
    applicant = application.user
    email_context = {
        'first_name': get_user_first_name(applicant),
        'message_for_applicant': message_for_applicant,
    }

    task_send_mandrill_email.delay(
        status_email_template_map[application.status], [applicant.email],
        email_context)
コード例 #3
0
def send_webinar_emails(template_slug,
                        webinar,
                        recipient_emails,
                        send_at=None):
    """
    Send webinar email to the list of given email addresses using the given template and data

    Arguments:
        template_slug (str): Slug for the chosen email template
        webinar (Webinar): Webinar object
        recipient_emails (iterable):  Iterable containing email addresses (str) to send the email to
        send_at (str): A String containing the time at which email will be sent

    Returns:
        None
    """
    context = {
        'webinar_id': webinar.id,
        'webinar_title': webinar.title,
        'webinar_description': webinar.description,
        'webinar_start_time': webinar.start_date_time_AST,
        'webinar_link': webinar.meeting_link,
    }

    if template_slug in [
            MandrillClient.WEBINAR_CREATED, MandrillClient.WEBINAR_TEAM_INVITE
    ]:
        context['register_link'] = get_webinar_description_link(webinar.id)

    task_send_mandrill_email.delay(template_slug, recipient_emails, context,
                                   send_at)
コード例 #4
0
def schedule_webinar_reminders(user_emails, webinar):
    """
    Schedule reminders for a webinar on mandrill.

    Args:
        user_emails (list): List of user emails to schedule reminders.
        webinar (Webinar): Webinar to schedule emails for.

    Returns:
        None
    """
    email_context = webinar.to_dict()

    task_send_mandrill_email.delay(MandrillClient.WEBINAR_TWO_HOURS_REMINDER,
                                   user_emails,
                                   email_context,
                                   webinar.start_time - timedelta(hours=2),
                                   save_mandrill_msg_ids=True)

    one_day_before_webinar_starts = webinar.start_time - timedelta(days=1)
    if one_day_before_webinar_starts >= timezone.now():
        task_send_mandrill_email.delay(MandrillClient.WEBINAR_ONE_DAY_REMINDER,
                                       user_emails,
                                       email_context,
                                       one_day_before_webinar_starts,
                                       save_mandrill_msg_ids=True)
コード例 #5
0
def send_team_member_invitation_email(recipient_email, registration_url):
    """
    Send team member invitation email to the recipient email

    Args:
        recipient_email (str): target email address to send the email to
        registration_url (str): registration url with query parameters related to the admin invitation
    """
    message_context = {'registration_url': registration_url}
    task_send_mandrill_email.delay(MandrillClient.TEAM_MEMBER_INVITATION,
                                   [recipient_email], message_context)
コード例 #6
0
def send_webinar_registration_email(webinar, email):
    """
    Send webinar registration email to user.

    Args:
        webinar (Webinar): The webinar in which user is registered
        email (str): User's email

    Returns:
        None
    """
    task_send_mandrill_email.delay(
        MandrillClient.WEBINAR_REGISTRATION_CONFIRMATION, [email], {
            'webinar_title': webinar.title,
            'webinar_description': webinar.description,
            'webinar_link': webinar.meeting_link,
            'webinar_start_time': webinar.start_date_time_AST
        })
コード例 #7
0
def compose_and_send_adg_course_enrollment_confirmation_email(user, course_id):
    """
    Prepare and send email for enrollment confirmation

    Arguments:
        user (User): Django user object
        course_id (str): Id of course

    Returns:
        None
    """
    course = CourseOverview.objects.get(id=course_id)
    root_url = configuration_helpers.get_value('LMS_ROOT_URL',
                                               settings.LMS_ROOT_URL)
    course_url = '{root_url}/courses/{course_id}'.format(root_url=root_url,
                                                         course_id=course.id)

    context = {'course_name': course.display_name, 'course_url': course_url}
    task_send_mandrill_email.delay(MandrillClient.ENROLLMENT_CONFIRMATION,
                                   [user.email], context)
コード例 #8
0
def send_application_submission_confirmation_emails(recipient_emails):
    """
    Send application submission confirmation email to the recipient emails

    Args:
        recipient_emails (list): target email addresses to send the email to

    Returns:
        None
    """
    root_url = configuration_helpers.get_value('LMS_ROOT_URL',
                                               settings.LMS_ROOT_URL)
    course_catalog_url = '{root_url}{course_catalog_url}'.format(
        root_url=root_url, course_catalog_url=reverse('courses'))

    context = {'course_catalog_url': course_catalog_url}

    task_send_mandrill_email.delay(
        MandrillClient.APPLICATION_SUBMISSION_CONFIRMATION, recipient_emails,
        context)