예제 #1
0
def _get_course_with_highlights(course_key):
    """ Gets Course descriptor iff highlights are enabled for the course """
    if not COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_key):
        raise CourseUpdateDoesNotExist(
            '{} Course Update Messages waffle flag is disabled.'.format(
                course_key))

    course_descriptor = _get_course_descriptor(course_key)
    if not course_descriptor.highlights_enabled_for_messaging:
        raise CourseUpdateDoesNotExist(
            '{} Course Update Messages are disabled.'.format(course_key))

    return course_descriptor
예제 #2
0
def course_has_highlights(course_key):
    """
    Does the course have any highlights for any section/week in it?
    This ignores access checks, since highlights may be lurking in currently
    inaccessible content.
    """
    if not COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_key):
        return False

    course = modulestore().get_course(course_key, depth=1)
    return any(
        section.highlights
        for section in course.get_children()
        if not section.hide_from_toc
    )
예제 #3
0
def _get_course_with_highlights(course_key):
    # pylint: disable=missing-docstring
    if not COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_key):
        raise CourseUpdateDoesNotExist(
            u"%s Course Update Messages waffle flag is disabled.",
            course_key,
        )

    course_descriptor = _get_course_descriptor(course_key)
    if not course_descriptor.highlights_enabled_for_messaging:
        raise CourseUpdateDoesNotExist(
            u"%s Course Update Messages are disabled.",
            course_key,
        )

    return course_descriptor
def _get_course_with_highlights(course_key):
    # pylint: disable=missing-docstring
    if not COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_key):
        raise CourseUpdateDoesNotExist(
            u"%s Course Update Messages waffle flag is disabled.",
            course_key,
        )

    course_descriptor = _get_course_descriptor(course_key)
    if not course_descriptor.highlights_enabled_for_messaging:
        raise CourseUpdateDoesNotExist(
            u"%s Course Update Messages are disabled.",
            course_key,
        )

    return course_descriptor
예제 #5
0
def get_week_highlights(user, course_key, week_num):
    """
    Get highlights (list of unicode strings) for a given week.
    week_num starts at 1.
    Raises CourseUpdateDoesNotExist if highlights do not exist for
    the requested week_num.
    """
    if not COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_key):
        raise CourseUpdateDoesNotExist(
            "%s does not have Course Updates enabled.",
            course_key
        )

    course_descriptor = _get_course_descriptor(course_key)
    course_module = _get_course_module(course_descriptor, user)
    sections_with_highlights = _get_sections_with_highlights(course_module)
    highlights = _get_highlights_for_week(sections_with_highlights, week_num, course_key)
    return highlights
예제 #6
0
def get_week_highlights(course_id, week_num):
    if COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_id):
        course = modulestore().get_course(course_id)
        return course.highlights_for_week(week_num)
    else:
        raise CourseUpdateDoesNotExist()
예제 #7
0
def get_course_week_summary(course_id, week_num):
    if COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_id):
        course = modulestore().get_course(course_id)
        return course.week_summary(week_num)
    else:
        raise CourseUpdateDoesNotExist()
예제 #8
0
파일: tasks.py 프로젝트: svejk/edx-platform
def get_course_week_summary(course_id, week_num):
    if COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_id):
        course = modulestore().get_course(course_id)
        return course.week_summary(week_num)
    else:
        raise CourseUpdateDoesNotExist()
예제 #9
0
def get_week_highlights(course_id, week_num):
    if COURSE_UPDATE_WAFFLE_FLAG.is_enabled(course_id):
        course = modulestore().get_course(course_id)
        return course.highlights_for_week(week_num)
    else:
        raise CourseUpdateDoesNotExist()