diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py
index a5999f263d..4a26d09ae9 100644
--- a/cms/djangoapps/contentstore/utils.py
+++ b/cms/djangoapps/contentstore/utils.py
@@ -195,6 +195,11 @@ def course_image_url(course):
class PublishState(object):
+ """
+ The publish state for a given xblock-- either 'draft', 'private', or 'public'.
+
+ Currently in CMS, an xblock can only be in 'draft' or 'private' if it is at or below the Unit level.
+ """
draft = 'draft'
private = 'private'
public = 'public'
diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py
index 2593bbbbca..4c68214aeb 100644
--- a/cms/djangoapps/contentstore/views/component.py
+++ b/cms/djangoapps/contentstore/views/component.py
@@ -107,8 +107,8 @@ def subsection_handler(request, tag=None, package_id=None, branch=None, version_
can_view_live = False
subsection_units = item.get_children()
for unit in subsection_units:
- state = compute_unit_state(unit)
- if state == UnitState.public or state == UnitState.draft:
+ state = compute_publish_state(unit)
+ if state == PublishState.public or state == PublishState.draft:
can_view_live = True
break
@@ -312,10 +312,8 @@ def container_handler(request, tag=None, package_id=None, branch=None, version_g
ancestor_xblocks = []
parent = get_parent_xblock(xblock)
- unit = None
while parent and parent.category != 'sequential':
ancestor_xblocks.append(parent)
- unit = parent
parent = get_parent_xblock(parent)
ancestor_xblocks.reverse()
@@ -324,7 +322,7 @@ def container_handler(request, tag=None, package_id=None, branch=None, version_g
'context_course': course,
'xblock': xblock,
'xblock_locator': locator,
- 'unit': unit,
+ 'unit': None if not ancestor_xblocks else ancestor_xblocks[0],
'ancestor_xblocks': ancestor_xblocks,
})
else:
diff --git a/cms/djangoapps/contentstore/views/tests/test_container.py b/cms/djangoapps/contentstore/views/tests/test_container.py
index 766b86f8f3..f26cb401ba 100644
--- a/cms/djangoapps/contentstore/views/tests/test_container.py
+++ b/cms/djangoapps/contentstore/views/tests/test_container.py
@@ -28,9 +28,9 @@ class ContainerViewTestCase(CourseTestCase):
def test_container_html(self):
self._test_html_content(
self.child_vertical,
- expected_section_tag='',
+ expected_section_tag='',
expected_breadcrumbs=(
- r'Unit\s*'
r'Child Vertical'),
)
@@ -46,11 +46,11 @@ class ContainerViewTestCase(CourseTestCase):
category="html", display_name="Child HTML")
self._test_html_content(
xblock_with_child,
- expected_section_tag='',
+ expected_section_tag='',
expected_breadcrumbs=(
- r'Unit\s*'
- r'Child Vertical\s*'
r'Wrapper'),
)
@@ -67,3 +67,6 @@ class ContainerViewTestCase(CourseTestCase):
self.assertIn(expected_section_tag, html)
# Verify the navigation link at the top of the page is correct.
self.assertRegexpMatches(html, expected_breadcrumbs)
+ # Verify the link that allows users to change publish status.
+ expected_unit_link = 'This container will publish as part of the unit Unit.'
+ self.assertIn(expected_unit_link, html)
diff --git a/cms/djangoapps/contentstore/views/tests/test_helpers.py b/cms/djangoapps/contentstore/views/tests/test_helpers.py
index d0bf3ffc24..cfefeb3e81 100644
--- a/cms/djangoapps/contentstore/views/tests/test_helpers.py
+++ b/cms/djangoapps/contentstore/views/tests/test_helpers.py
@@ -16,7 +16,7 @@ class HelpersTestCase(CourseTestCase):
# Verify course URL
self.assertEqual(xblock_studio_url(course),
- u'/course/MITx.999.Robot_Super_Course/branch/published/block/Robot_Super_Course')
+ u'/course/MITx.999.Robot_Super_Course/branch/draft/block/Robot_Super_Course')
# Verify chapter URL
chapter = ItemFactory.create(parent_location=self.course.location, category='chapter',
@@ -34,17 +34,17 @@ class HelpersTestCase(CourseTestCase):
vertical = ItemFactory.create(parent_location=sequential.location, category='vertical',
display_name='Unit')
self.assertEqual(xblock_studio_url(vertical),
- u'/unit/MITx.999.Robot_Super_Course/branch/published/block/Unit')
+ u'/unit/MITx.999.Robot_Super_Course/branch/draft/block/Unit')
self.assertEqual(xblock_studio_url(vertical, course),
- u'/unit/MITx.999.Robot_Super_Course/branch/published/block/Unit')
+ u'/unit/MITx.999.Robot_Super_Course/branch/draft/block/Unit')
# Verify child vertical URL
child_vertical = ItemFactory.create(parent_location=vertical.location, category='vertical',
display_name='Child Vertical')
self.assertEqual(xblock_studio_url(child_vertical),
- u'/container/MITx.999.Robot_Super_Course/branch/published/block/Child_Vertical')
+ u'/container/MITx.999.Robot_Super_Course/branch/draft/block/Child_Vertical')
self.assertEqual(xblock_studio_url(child_vertical, course),
- u'/container/MITx.999.Robot_Super_Course/branch/published/block/Child_Vertical')
+ u'/container/MITx.999.Robot_Super_Course/branch/draft/block/Child_Vertical')
# Verify video URL
video = ItemFactory.create(parent_location=child_vertical.location, category="video",
diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py
index 65d3642edf..09faceeea1 100644
--- a/cms/djangoapps/contentstore/views/tests/test_item.py
+++ b/cms/djangoapps/contentstore/views/tests/test_item.py
@@ -154,7 +154,7 @@ class GetItem(ItemTest):
html,
# The instance of the wrapper class will have an auto-generated ID (wrapperxxx). Allow anything
# for the 3 characters after wrapper.
- (r'"/container/MITx.999.Robot_Super_Course/branch/published/block/wrapper.{3}" class="action-button">\s*'
+ (r'"/container/MITx.999.Robot_Super_Course/branch/draft/block/wrapper.{3}" class="action-button">\s*'
'View')
)
@@ -657,7 +657,6 @@ class TestEditItem(ItemTest):
draft = self.get_item_from_modulestore(self.problem_locator, True)
self.assertNotEqual(draft.data, published.data)
-
def test_publish_states_of_nested_xblocks(self):
""" Test publishing of a unit page containing a nested xblock """