Merge pull request #26744 from edx/AA-461
[AA-461] Export highlights to s3 for use by braze
This commit is contained in:
@@ -14,6 +14,22 @@ from xmodule.modulestore.django import modulestore
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_all_course_highlights(course_key):
|
||||
"""
|
||||
This ignores access checks, since highlights may be lurking in currently
|
||||
inaccessible content.
|
||||
Returns a list of all the section highlights in the course
|
||||
"""
|
||||
try:
|
||||
course = _get_course_with_highlights(course_key)
|
||||
|
||||
except CourseUpdateDoesNotExist:
|
||||
return []
|
||||
else:
|
||||
highlights = [section.highlights for section in course.get_children() if not section.hide_from_toc]
|
||||
return highlights
|
||||
|
||||
|
||||
def course_has_highlights(course):
|
||||
"""
|
||||
Does the course have any highlights for any section/week in it?
|
||||
|
||||
@@ -5,6 +5,7 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
from openedx.core.djangoapps.schedules.content_highlights import (
|
||||
course_has_highlights_from_store,
|
||||
get_all_course_highlights,
|
||||
get_next_section_highlights,
|
||||
get_week_highlights
|
||||
)
|
||||
@@ -58,6 +59,14 @@ class TestContentHighlights(ModuleStoreTestCase): # lint-amnesty, pylint: disab
|
||||
assert course_has_highlights_from_store(self.course_key)
|
||||
assert get_week_highlights(self.user, self.course_key, week_num=1) == highlights
|
||||
|
||||
def test_get_all_course_highlights(self):
|
||||
all_highlights = [["week1highlight1", "week1highlight2"], ["week1highlight1", "week1highlight2"], [], []]
|
||||
with self.store.bulk_operations(self.course_key):
|
||||
for week_highlights in all_highlights:
|
||||
self._create_chapter(highlights=week_highlights)
|
||||
|
||||
assert get_all_course_highlights(self.course_key) == all_highlights
|
||||
|
||||
def test_highlights_disabled_for_messaging(self):
|
||||
highlights = ['A test highlight.']
|
||||
with self.store.bulk_operations(self.course_key):
|
||||
|
||||
Reference in New Issue
Block a user