Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
dd22bf49
Commit
dd22bf49
authored
Mar 12, 2014
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests and minor cleanup.
parent
3bb4be7d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
17 deletions
+22
-17
cms/djangoapps/contentstore/utils.py
+5
-0
cms/djangoapps/contentstore/views/component.py
+3
-5
cms/djangoapps/contentstore/views/tests/test_container.py
+8
-5
cms/djangoapps/contentstore/views/tests/test_helpers.py
+5
-5
cms/djangoapps/contentstore/views/tests/test_item.py
+1
-2
No files found.
cms/djangoapps/contentstore/utils.py
View file @
dd22bf49
...
...
@@ -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'
...
...
cms/djangoapps/contentstore/views/component.py
View file @
dd22bf49
...
...
@@ -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
==
Unit
State
.
draft
:
state
=
compute_
publish
_state
(
unit
)
if
state
==
PublishState
.
public
or
state
==
Publish
State
.
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
:
...
...
cms/djangoapps/contentstore/views/tests/test_container.py
View file @
dd22bf49
...
...
@@ -28,9 +28,9 @@ class ContainerViewTestCase(CourseTestCase):
def
test_container_html
(
self
):
self
.
_test_html_content
(
self
.
child_vertical
,
expected_section_tag
=
'<section class="wrapper-xblock level-page" data-locator="MITx.999.Robot_Super_Course/branch/
published
/block/Child_Vertical"/>'
,
expected_section_tag
=
'<section class="wrapper-xblock level-page" data-locator="MITx.999.Robot_Super_Course/branch/
draft
/block/Child_Vertical"/>'
,
expected_breadcrumbs
=
(
r'<a href="/unit/MITx.999.Robot_Super_Course/branch/
published
/block/Unit"\s*'
r'<a href="/unit/MITx.999.Robot_Super_Course/branch/
draft
/block/Unit"\s*'
r'class="navigation-link navigation-parent">Unit</a>\s*'
r'<a href="#" class="navigation-link navigation-current">Child Vertical</a>'
),
)
...
...
@@ -46,11 +46,11 @@ class ContainerViewTestCase(CourseTestCase):
category
=
"html"
,
display_name
=
"Child HTML"
)
self
.
_test_html_content
(
xblock_with_child
,
expected_section_tag
=
'<section class="wrapper-xblock level-page" data-locator="MITx.999.Robot_Super_Course/branch/
published
/block/Wrapper"/>'
,
expected_section_tag
=
'<section class="wrapper-xblock level-page" data-locator="MITx.999.Robot_Super_Course/branch/
draft
/block/Wrapper"/>'
,
expected_breadcrumbs
=
(
r'<a href="/unit/MITx.999.Robot_Super_Course/branch/
published
/block/Unit"\s*'
r'<a href="/unit/MITx.999.Robot_Super_Course/branch/
draft
/block/Unit"\s*'
r'class="navigation-link navigation-parent">Unit</a>\s*'
r'<a href="/container/MITx.999.Robot_Super_Course/branch/
published
/block/Child_Vertical"\s*'
r'<a href="/container/MITx.999.Robot_Super_Course/branch/
draft
/block/Child_Vertical"\s*'
r'class="navigation-link navigation-parent">Child Vertical</a>\s*'
r'<a href="#" class="navigation-link navigation-current">Wrapper</a>'
),
)
...
...
@@ -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 <a href="/unit/MITx.999.Robot_Super_Course/branch/draft/block/Unit">Unit</a>.'
self
.
assertIn
(
expected_unit_link
,
html
)
cms/djangoapps/contentstore/views/tests/test_helpers.py
View file @
dd22bf49
...
...
@@ -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"
,
...
...
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
dd22bf49
...
...
@@ -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*'
'<span class="action-button-text">View</span>'
)
)
...
...
@@ -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 """
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment