Ejemplo n.º 1
0
def handle_enroll_status_change(sender,
                                event=None,
                                user=None,
                                mode=None,
                                course_id=None,
                                **kwargs):  # pylint: disable=unused-argument
    """
    Signal receiver for enroll/unenroll/purchase events
    """
    email_config = EmailMarketingConfiguration.current()
    if not email_config.enabled or not event or not user or not mode or not course_id:
        return

    # skip tracking (un)enrolls if simulated cost=0
    if email_config.sailthru_enroll_cost == 0:
        return

    request = crum.get_current_request()
    if not request:
        return

    # get string course_id serializable to send through celery
    course_id_string = unicode(course_id)

    # figure out course url
    course_url = _build_course_url(request, course_id_string, email_config)

    # pass event to email_marketing.tasks
    update_course_enrollment.delay(
        user.email,
        course_url,
        event,
        mode,
        course_id=course_id_string,
        message_id=request.COOKIES.get('sailthru_bid'))
Ejemplo n.º 2
0
def handle_enroll_status_change(sender, event=None, user=None, mode=None, course_id=None,
                                **kwargs):  # pylint: disable=unused-argument
    """
    Signal receiver for enroll/unenroll/purchase events
    """
    email_config = EmailMarketingConfiguration.current()
    if not email_config.enabled or not event or not user or not mode or not course_id:
        return

    # skip tracking (un)enrolls if simulated cost=0
    if email_config.sailthru_enroll_cost == 0:
        return

    request = crum.get_current_request()
    if not request:
        return

    # get string course_id serializable to send through celery
    course_id_string = unicode(course_id)

    # figure out course url
    course_url = _build_course_url(request, course_id_string, email_config)

    # pass event to email_marketing.tasks
    update_course_enrollment.delay(user.email, course_url, event, mode,
                                   course_id=course_id_string,
                                   message_id=request.COOKIES.get('sailthru_bid'))
def handle_enroll_status_change(sender,
                                event=None,
                                user=None,
                                mode=None,
                                course_id=None,
                                cost=None,
                                currency=None,
                                **kwargs):  # pylint: disable=unused-argument
    """
    Signal receiver for enroll/unenroll/purchase events
    """
    email_config = EmailMarketingConfiguration.current()
    if not email_config.enabled or not event or not user or not mode or not course_id:
        return

    request = crum.get_current_request()
    if not request:
        return

    # figure out course url
    course_url = _build_course_url(request, course_id.to_deprecated_string())

    # pass event to email_marketing.tasks
    update_course_enrollment.delay(
        user.email,
        course_url,
        event,
        mode,
        unit_cost=cost,
        course_id=course_id,
        currency=currency,
        message_id=request.COOKIES.get('sailthru_bid'))
Ejemplo n.º 4
0
def update_sailthru(sender, user, mode, course_id, **kwargs):  # pylint: disable=unused-argument
    """
    Receives signal and calls a celery task to update the
    enrollment track
    Arguments:
        user: current user
        course_id: course key of a course
    Returns:
        None
    """
    if WAFFLE_SWITCHES.is_enabled(SAILTHRU_AUDIT_PURCHASE_ENABLED) and mode in CourseMode.AUDIT_MODES:
        email = user.email.encode('utf-8')
        update_course_enrollment.delay(email, course_id, mode, site=_get_current_site())
Ejemplo n.º 5
0
def handle_enroll_status_change(sender, event=None, user=None, mode=None, course_id=None, cost=None, currency=None,
                                **kwargs):  # pylint: disable=unused-argument
    """
    Signal receiver for enroll/unenroll/purchase events
    """
    email_config = EmailMarketingConfiguration.current()
    if not email_config.enabled or not event or not user or not mode or not course_id:
        return

    request = crum.get_current_request()
    if not request:
        return

    # figure out course url
    course_url = _build_course_url(request, course_id.to_deprecated_string())

    # pass event to email_marketing.tasks
    update_course_enrollment.delay(user.email, course_url, event, mode,
                                   unit_cost=cost, course_id=course_id, currency=currency,
                                   message_id=request.COOKIES.get('sailthru_bid'))