diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 42b3d8a60a..1a22ec1a6b 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -121,23 +121,10 @@ def container_handler(request, usage_key_string): component_templates = get_component_templates(course) ancestor_xblocks = [] - parent = get_parent_xblock(xblock) action = request.GET.get('action', 'view') is_unit_page = is_unit(xblock) - unit = xblock if is_unit_page else None - - is_first = True - while parent: - if unit is None and is_unit(parent): - unit = parent - elif parent.category != 'sequential': - current_block = {'block': parent, 'children': parent.get_children(), 'is_last': is_first} - is_first = False - ancestor_xblocks.append(current_block) - parent = get_parent_xblock(parent) - - ancestor_xblocks.reverse() + unit = xblock if is_unit_page else get_parent_xblock(xblock) assert unit is not None, "Could not determine unit page" subsection = get_parent_xblock(unit) @@ -146,6 +133,15 @@ def container_handler(request, usage_key_string): section = get_parent_xblock(subsection) assert section is not None, "Could not determine ancestor section from unit " + six.text_type(unit.location) + # build the breadcrumbs + for block in (section, subsection): + parent = get_parent_xblock(block) + ancestor_xblocks.append({ + 'title': block.display_name_with_default, + 'children': parent.get_children(), + 'is_last': block.category == 'sequential' + }) + # for the sequence navigator prev_url, next_url = get_sibling_urls(subsection) # these are quoted here because they'll end up in a query string on the page, diff --git a/cms/djangoapps/contentstore/views/tests/test_container_page.py b/cms/djangoapps/contentstore/views/tests/test_container_page.py index d718223129..67ea4dc905 100644 --- a/cms/djangoapps/contentstore/views/tests/test_container_page.py +++ b/cms/djangoapps/contentstore/views/tests/test_container_page.py @@ -88,11 +88,11 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase): u'data-locator="{0}" data-course-key="{0.course_key}">'.format(draft_container.location) ), expected_breadcrumbs=( - u'Week 1.*' u'Lesson 1.*' + u'Unit.*' ).format( course=re.escape(six.text_type(self.course.id)), - section_parameters=re.escape(u'?show={}'.format(http.urlquote(self.chapter.location))), + unit_parameters=re.escape(str(self.vertical.location)), subsection_parameters=re.escape(u'?show={}'.format(http.urlquote(self.sequential.location))), ), ) diff --git a/cms/templates/container.html b/cms/templates/container.html index 938766c45e..235aa57518 100644 --- a/cms/templates/container.html +++ b/cms/templates/container.html @@ -90,7 +90,7 @@ from openedx.core.djangolib.markup import HTML, Text
    % for block in ancestor_xblocks: