refactor: rename get_displayable_items and displayable_items
This commit is contained in:
@@ -912,7 +912,7 @@ def get_current_child(xmodule, min_depth=None, requested_child=None):
|
||||
else:
|
||||
content_children = [
|
||||
child for child in child_modules
|
||||
if child.has_children_at_depth(min_depth - 1) and child.get_display_items()
|
||||
if child.has_children_at_depth(min_depth - 1) and child.get_display_blocks()
|
||||
]
|
||||
return _get_child(content_children) if content_children else None
|
||||
|
||||
@@ -926,7 +926,7 @@ def get_current_child(xmodule, min_depth=None, requested_child=None):
|
||||
return child
|
||||
|
||||
if has_position:
|
||||
children = xmodule.get_display_items()
|
||||
children = xmodule.get_display_blocks()
|
||||
if len(children) > 0:
|
||||
if xmodule.position is not None and not requested_child:
|
||||
pos = int(xmodule.position) - 1 # position is 1-indexed
|
||||
|
||||
@@ -162,7 +162,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, field_
|
||||
return None, None, None
|
||||
|
||||
toc_chapters = []
|
||||
chapters = course_block.get_display_items()
|
||||
chapters = course_block.get_display_blocks()
|
||||
|
||||
# Check for content which needs to be completed
|
||||
# before the rest of the content is made available
|
||||
@@ -190,7 +190,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, field_
|
||||
continue
|
||||
|
||||
sections = []
|
||||
for section in chapter.get_display_items():
|
||||
for section in chapter.get_display_blocks():
|
||||
# skip the section if it is hidden from the user
|
||||
if section.hide_from_toc:
|
||||
continue
|
||||
|
||||
@@ -166,7 +166,7 @@ class CoursesTest(ModuleStoreTestCase):
|
||||
assert get_current_child(mock_xmodule) is None
|
||||
|
||||
mock_xmodule.position = -1
|
||||
mock_xmodule.get_display_items.return_value = ['one', 'two', 'three']
|
||||
mock_xmodule.get_display_blocks.return_value = ['one', 'two', 'three']
|
||||
assert get_current_child(mock_xmodule) == 'one'
|
||||
|
||||
mock_xmodule.position = 2
|
||||
@@ -175,7 +175,7 @@ class CoursesTest(ModuleStoreTestCase):
|
||||
assert get_current_child(mock_xmodule, requested_child='last') == 'three'
|
||||
|
||||
mock_xmodule.position = 3
|
||||
mock_xmodule.get_display_items.return_value = []
|
||||
mock_xmodule.get_display_blocks.return_value = []
|
||||
assert get_current_child(mock_xmodule) is None
|
||||
|
||||
|
||||
|
||||
@@ -491,7 +491,7 @@ class CoursewareIndex(View):
|
||||
exceeds the length of the displayable items, default the position
|
||||
to the first element.
|
||||
"""
|
||||
display_items = self.section.get_display_items()
|
||||
display_items = self.section.get_display_blocks()
|
||||
if not display_items:
|
||||
return
|
||||
if self.section.position > len(display_items):
|
||||
@@ -565,7 +565,7 @@ def save_child_position(seq_block, child_name):
|
||||
"""
|
||||
child_name: url_name of the child
|
||||
"""
|
||||
for position, child in enumerate(seq_block.get_display_items(), start=1):
|
||||
for position, child in enumerate(seq_block.get_display_blocks(), start=1):
|
||||
if child.location.block_id == child_name:
|
||||
# Only save if position changed
|
||||
if position != seq_block.position:
|
||||
|
||||
@@ -819,7 +819,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
|
||||
"""
|
||||
mock_course_block = MagicMock()
|
||||
mock_course_block.position = 3
|
||||
mock_course_block.get_display_items.return_value = []
|
||||
mock_course_block.get_display_blocks.return_value = []
|
||||
assert helpers.get_course_position(mock_course_block) is None
|
||||
|
||||
def test_get_course_position_to_chapter(self):
|
||||
@@ -833,7 +833,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
|
||||
mock_chapter.url_name = 'chapter_url_name'
|
||||
mock_chapter.display_name_with_default = 'Test Chapter Display Name'
|
||||
|
||||
mock_course_block.get_display_items.return_value = [mock_chapter]
|
||||
mock_course_block.get_display_blocks.return_value = [mock_chapter]
|
||||
|
||||
assert helpers.get_course_position(mock_course_block) == {
|
||||
'display_name': 'Test Chapter Display Name',
|
||||
@@ -845,7 +845,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
|
||||
Returns `None` if no section found.
|
||||
"""
|
||||
mock_course_block = MagicMock(id=self.course.id, position=None)
|
||||
mock_course_block.get_display_items.return_value = [MagicMock()]
|
||||
mock_course_block.get_display_blocks.return_value = [MagicMock()]
|
||||
assert helpers.get_course_position(mock_course_block) is None
|
||||
|
||||
def test_get_course_position_to_section(self):
|
||||
@@ -857,14 +857,14 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
|
||||
|
||||
mock_chapter = MagicMock()
|
||||
mock_chapter.url_name = 'chapter_url_name'
|
||||
mock_course_block.get_display_items.return_value = [mock_chapter]
|
||||
mock_course_block.get_display_blocks.return_value = [mock_chapter]
|
||||
|
||||
mock_section = MagicMock()
|
||||
mock_section.url_name = 'section_url_name'
|
||||
mock_section.display_name_with_default = 'Test Section Display Name'
|
||||
|
||||
mock_chapter.get_display_items.return_value = [mock_section]
|
||||
mock_section.get_display_items.return_value = [MagicMock()]
|
||||
mock_chapter.get_display_blocks.return_value = [mock_section]
|
||||
mock_section.get_display_blocks.return_value = [MagicMock()]
|
||||
|
||||
assert helpers.get_course_position(mock_course_block) == {
|
||||
'display_name': 'Test Section Display Name',
|
||||
|
||||
Reference in New Issue
Block a user