diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 514b89d419..dda94a072e 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -122,10 +122,36 @@ 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 get_parent_xblock(xblock) + unit = xblock if is_unit_page else None + + is_first = True + block = xblock + + # Build the breadcrumbs and find the ``Unit`` ancestor + # if it is not the immediate parent. + while parent: + + if unit is None and is_unit(block): + unit = block + + # add all to nav except current xblock page + if xblock != block: + current_block = { + 'title': block.display_name_with_default, + 'children': parent.get_children(), + 'is_last': is_first + } + is_first = False + ancestor_xblocks.append(current_block) + + block = parent + parent = get_parent_xblock(parent) + + ancestor_xblocks.reverse() assert unit is not None, "Could not determine unit page" subsection = get_parent_xblock(unit) @@ -134,15 +160,6 @@ 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/templates/container.html b/cms/templates/container.html index e5e6d84de7..cbe4b1908c 100644 --- a/cms/templates/container.html +++ b/cms/templates/container.html @@ -64,7 +64,7 @@ from openedx.core.djangolib.markup import HTML, Text $('.seq_new_button').click(function(evt) { evt.preventDefault(); XBlockUtils.addXBlock($(evt.target)).done(function(locator) { - ViewUtils.redirect('/container/' + locator + '?action=new'); + ViewUtils.redirect('/container/' + locator + '?action=new'); return false; }); return false; @@ -100,9 +100,17 @@ from openedx.core.djangolib.markup import HTML, Text @@ -123,6 +131,7 @@ from openedx.core.djangolib.markup import HTML, Text + % if is_unit_page:
+ % endif