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
0dbabc7a
Commit
0dbabc7a
authored
Mar 04, 2014
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support xblocks with children on the container page.
STUD-1363
parent
92411bd2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
19 deletions
+90
-19
cms/djangoapps/contentstore/views/component.py
+9
-2
cms/djangoapps/contentstore/views/item.py
+3
-5
cms/djangoapps/contentstore/views/preview.py
+2
-0
cms/djangoapps/contentstore/views/tests/test_container.py
+38
-2
cms/djangoapps/contentstore/views/tests/test_item.py
+23
-0
cms/static/sass/elements/_xblocks.scss
+1
-1
cms/templates/container.html
+9
-7
cms/templates/container_xblock_component.html
+5
-2
No files found.
cms/djangoapps/contentstore/views/component.py
View file @
0dbabc7a
...
...
@@ -310,13 +310,20 @@ def container_handler(request, tag=None, package_id=None, branch=None, version_g
old_location
,
course
,
xblock
,
__
=
_get_item_in_course
(
request
,
locator
)
except
ItemNotFoundError
:
return
HttpResponseBadRequest
()
parent_xblock
=
get_parent_xblock
(
xblock
)
parent_xblocks
=
[]
parent
=
get_parent_xblock
(
xblock
)
while
parent
and
parent
.
category
!=
'sequential'
:
parent_xblocks
.
append
(
parent
)
parent
=
get_parent_xblock
(
parent
)
parent_xblocks
.
reverse
()
return
render_to_response
(
'container.html'
,
{
'context_course'
:
course
,
'xblock'
:
xblock
,
'xblock_locator'
:
locator
,
'parent_xblock
'
:
parent_xblock
,
'parent_xblock
s'
:
parent_xblocks
,
})
else
:
return
HttpResponseBadRequest
(
"Only supports html requests"
)
...
...
cms/djangoapps/contentstore/views/item.py
View file @
0dbabc7a
...
...
@@ -206,12 +206,10 @@ def xblock_view_handler(request, package_id, view_name, tag=None, branch=None, v
elif
view_name
==
'student_view'
and
component
.
has_children
:
# For non-leaf xblocks on the unit page, show the special rendering
# which links to the new container page.
course_location
=
loc_mapper
()
.
translate_locator_to_location
(
locator
,
True
)
course
=
store
.
get_item
(
course_location
)
html
=
render_to_string
(
'unit_container_xblock_component.html'
,
{
'course'
:
course
,
html
=
render_to_string
(
'container_xblock_component.html'
,
{
'xblock'
:
component
,
'locator'
:
locator
'locator'
:
locator
,
'reordering_enabled'
:
True
,
})
return
JsonResponse
({
'html'
:
html
,
...
...
cms/djangoapps/contentstore/views/preview.py
View file @
0dbabc7a
...
...
@@ -179,6 +179,8 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
}
if
xblock
.
category
==
'vertical'
:
template
=
'studio_vertical_wrapper.html'
elif
xblock
.
location
!=
context
.
get
(
'root_xblock'
)
.
location
and
xblock
.
has_children
:
template
=
'container_xblock_component.html'
else
:
template
=
'studio_xblock_wrapper.html'
html
=
render_to_string
(
template
,
template_context
)
...
...
cms/djangoapps/contentstore/views/tests/test_container.py
View file @
0dbabc7a
...
...
@@ -26,8 +26,44 @@ class ContainerViewTestCase(CourseTestCase):
category
=
"video"
,
display_name
=
"My Video"
)
def
test_container_html
(
self
):
url
=
xblock_studio_url
(
self
.
child_vertical
)
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_breadcrumbs
=
(
r'<a href="/unit/MITx.999.Robot_Super_Course/branch/published/block/Unit"\s*'
r'class="navigation-link navigation-parent">Unit</a>\s*'
r'<a href="#" class="navigation-link navigation-current">Child Vertical</a>'
),
)
def
test_container_on_container_html
(
self
):
"""
Create the scenario of an xblock with children (non-vertical) on the container page.
This should create a container page that is a child of another container page.
"""
xblock_with_child
=
ItemFactory
.
create
(
parent_location
=
self
.
child_vertical
.
location
,
category
=
"wrapper"
,
display_name
=
"Wrapper"
)
ItemFactory
.
create
(
parent_location
=
xblock_with_child
.
location
,
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_breadcrumbs
=
(
r'<a href="/unit/MITx.999.Robot_Super_Course/branch/published/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'class="navigation-link navigation-parent">Child Vertical</a>\s*'
r'<a href="#" class="navigation-link navigation-current">Wrapper</a>'
),
)
def
_test_html_content
(
self
,
xblock
,
expected_section_tag
,
expected_breadcrumbs
):
"""
Get the HTML for a container page and verify the section tag is correct
and the breadcrumbs trail is correct.
"""
url
=
xblock_studio_url
(
xblock
,
self
.
course
)
resp
=
self
.
client
.
get_html
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
html
=
resp
.
content
self
.
assertIn
(
'<section class="wrapper-xblock level-page" data-locator="MITx.999.Robot_Super_Course/branch/published/block/Child_Vertical"/>'
,
html
)
self
.
assertIn
(
expected_section_tag
,
html
)
# Verify the navigation link at the top of the page is correct.
self
.
assertRegexpMatches
(
html
,
expected_breadcrumbs
)
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
0dbabc7a
...
...
@@ -132,6 +132,29 @@ class GetItem(ItemTest):
# Verify that the Studio element wrapper has been added
self
.
assertIn
(
'level-element'
,
html
)
def
test_get_container_nested_container_fragment
(
self
):
"""
Test the case of the container page containing a link to another container page.
"""
# Add a wrapper with child beneath a child vertical
root_locator
=
self
.
_create_vertical
()
resp
=
self
.
create_xblock
(
parent_locator
=
root_locator
,
category
=
"wrapper"
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
wrapper_locator
=
self
.
response_locator
(
resp
)
resp
=
self
.
create_xblock
(
parent_locator
=
wrapper_locator
,
category
=
'problem'
,
boilerplate
=
'multiplechoice.yaml'
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# Get the preview HTML and verify the View -> link is present.
html
,
__
=
self
.
_get_container_preview
(
root_locator
)
self
.
assertIn
(
'wrapper-xblock'
,
html
)
self
.
assertRegexpMatches
(
html
,
(
r'"/container/MITx.999.Robot_Super_Course/branch/published/block/wrapper.{3}" class="action-button">\s*'
'<span class="action-button-text">View</span>'
)
)
class
DeleteItem
(
ItemTest
):
"""Tests for '/xblock' DELETE url."""
...
...
cms/static/sass/elements/_xblocks.scss
View file @
0dbabc7a
...
...
@@ -55,7 +55,7 @@
}
// UI: xblock is collapsible
.wrapper-xblock.is-collapsible
{
.wrapper-xblock.is-collapsible
,
.wrapper-xblock.xblock-type-container
{
[
class
^=
"icon-"
]
{
font-style
:
normal
;
...
...
cms/templates/container.html
View file @
0dbabc7a
...
...
@@ -47,13 +47,15 @@ xblock_info = {
<header
class=
"mast has-actions has-navigation"
>
<h1
class=
"page-header"
>
<small
class=
"navigation navigation-parents"
>
<
%
parent_url =
xblock_studio_url(parent_xblock,
context_course
)
%
>
% if parent_url:
<a
href=
"${parent_url}"
class=
"navigation-link navigation-parent"
>
${parent_xblock.display_name | h}
</a>
% endif
% for parent in parent_xblocks:
<
%
parent_url =
xblock_studio_url(parent,
context_course
)
%
>
% if parent_url:
<a
href=
"${parent_url}"
class=
"navigation-link navigation-parent"
>
${parent.display_name | h}
</a>
% endif
% endfor
<a
href=
"#"
class=
"navigation-link navigation-current"
>
${xblock.display_name | h}
</a>
</small>
</h1>
...
...
cms/templates/
unit_
container_xblock_component.html
→
cms/templates/container_xblock_component.html
View file @
0dbabc7a
...
...
@@ -12,7 +12,7 @@ from contentstore.views.helpers import xblock_studio_url
<div
class=
"header-actions"
>
<ul
class=
"actions-list"
>
<li
class=
"action-item action-view"
>
<a
href=
"${xblock_studio_url(xblock
, course
)}"
class=
"action-button"
>
<a
href=
"${xblock_studio_url(xblock)}"
class=
"action-button"
>
## Translators: this is a verb describing the action of viewing more details
<span
class=
"action-button-text"
>
${_('View')}
</span>
<i
class=
"icon-arrow-right"
></i>
...
...
@@ -21,5 +21,8 @@ from contentstore.views.helpers import xblock_studio_url
</ul>
</div>
</header>
<span
data-tooltip=
"${_("
Drag
to
reorder
")}"
class=
"drag-handle"
></span>
## We currently support reordering only on the unit page.
% if reordering_enabled:
<span
data-tooltip=
"${_("
Drag
to
reorder
")}"
class=
"drag-handle"
></span>
% endif
</section>
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