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
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 )
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
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
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()
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()
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()
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()