Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-utils
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
xblock-utils
Commits
3b58c757
Commit
3b58c757
authored
Sep 04, 2015
by
Eugeny Kolpakov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #24 from edx/studio_container_with_nested
Added boilerplate parameter for Nested blocks spec + test
parents
eacc239c
8f4e7689
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
4 deletions
+20
-4
tests/integration/test_studio_editable.py
+6
-3
xblockutils/studio_editable.py
+13
-1
xblockutils/templates/add_buttons.html
+1
-0
No files found.
tests/integration/test_studio_editable.py
View file @
3b58c757
...
@@ -355,7 +355,7 @@ class XBlockWithNested(StudioContainerWithNestedXBlocksMixin, XBlock):
...
@@ -355,7 +355,7 @@ class XBlockWithNested(StudioContainerWithNestedXBlocksMixin, XBlock):
def
allowed_nested_blocks
(
self
):
def
allowed_nested_blocks
(
self
):
return
[
return
[
EditableXBlock
,
EditableXBlock
,
NestedXBlockSpec
(
FancyBlockShim
,
single_instance
=
True
)
NestedXBlockSpec
(
FancyBlockShim
,
single_instance
=
True
,
boilerplate
=
"fancy-boiler"
)
]
]
...
@@ -378,12 +378,13 @@ class StudioContainerWithNestedXBlocksTest(StudioContainerWithNestedXBlocksBaseT
...
@@ -378,12 +378,13 @@ class StudioContainerWithNestedXBlocksTest(StudioContainerWithNestedXBlocksBaseT
self
.
addCleanup
(
patcher
.
stop
)
self
.
addCleanup
(
patcher
.
stop
)
def
_check_button
(
self
,
button
,
category
,
label
,
single
,
disabled
,
disabled_reason
=
''
):
def
_check_button
(
self
,
button
,
category
,
label
,
single
,
disabled
,
disabled_reason
=
''
,
boilerplate
=
None
):
self
.
assertEqual
(
button
.
get_attribute
(
'data-category'
),
category
)
self
.
assertEqual
(
button
.
get_attribute
(
'data-category'
),
category
)
self
.
assertEqual
(
button
.
text
,
label
)
self
.
assertEqual
(
button
.
text
,
label
)
self
.
assertEqual
(
button
.
get_attribute
(
'data-single-instance'
),
str
(
single
)
.
lower
())
self
.
assertEqual
(
button
.
get_attribute
(
'data-single-instance'
),
str
(
single
)
.
lower
())
self
.
_assert_disabled
(
button
,
disabled
)
self
.
_assert_disabled
(
button
,
disabled
)
self
.
assertEqual
(
button
.
get_attribute
(
'title'
),
disabled_reason
)
self
.
assertEqual
(
button
.
get_attribute
(
'title'
),
disabled_reason
)
self
.
assertEqual
(
button
.
get_attribute
(
'data-boilerplate'
),
boilerplate
)
def
_assert_disabled
(
self
,
button
,
disabled
):
def
_assert_disabled
(
self
,
button
,
disabled
):
if
disabled
:
if
disabled
:
...
@@ -405,7 +406,9 @@ class StudioContainerWithNestedXBlocksTest(StudioContainerWithNestedXBlocksBaseT
...
@@ -405,7 +406,9 @@ class StudioContainerWithNestedXBlocksTest(StudioContainerWithNestedXBlocksBaseT
self
.
assertEqual
(
len
(
add_buttons
),
2
)
self
.
assertEqual
(
len
(
add_buttons
),
2
)
button_editable
,
button_fancy
=
add_buttons
button_editable
,
button_fancy
=
add_buttons
self
.
_check_button
(
button_editable
,
EditableXBlock
.
CATEGORY
,
EditableXBlock
.
STUDIO_LABEL
,
False
,
False
)
self
.
_check_button
(
button_editable
,
EditableXBlock
.
CATEGORY
,
EditableXBlock
.
STUDIO_LABEL
,
False
,
False
)
self
.
_check_button
(
button_fancy
,
FancyBlockShim
.
CATEGORY
,
FancyBlockShim
.
STUDIO_LABEL
,
True
,
False
)
self
.
_check_button
(
button_fancy
,
FancyBlockShim
.
CATEGORY
,
FancyBlockShim
.
STUDIO_LABEL
,
True
,
False
,
boilerplate
=
"fancy-boiler"
)
@XBlock.register_temp_plugin
(
XBlockWithDisabledNested
,
"nested"
)
@XBlock.register_temp_plugin
(
XBlockWithDisabledNested
,
"nested"
)
def
test_author_edit_view_nested_with_disabled
(
self
):
def
test_author_edit_view_nested_with_disabled
(
self
):
...
...
xblockutils/studio_editable.py
View file @
3b58c757
...
@@ -335,11 +335,12 @@ class NestedXBlockSpec(object):
...
@@ -335,11 +335,12 @@ class NestedXBlockSpec(object):
Class that allows detailed specification of allowed nested XBlocks. For use with
Class that allows detailed specification of allowed nested XBlocks. For use with
StudioContainerWithNestedXBlocksMixin.allowed_nested_blocks
StudioContainerWithNestedXBlocksMixin.allowed_nested_blocks
"""
"""
def
__init__
(
self
,
block
,
single_instance
=
False
,
disabled
=
False
,
disabled_reason
=
None
):
def
__init__
(
self
,
block
,
single_instance
=
False
,
disabled
=
False
,
disabled_reason
=
None
,
boilerplate
=
None
):
self
.
_block
=
block
self
.
_block
=
block
self
.
_single_instance
=
single_instance
self
.
_single_instance
=
single_instance
self
.
_disabled
=
disabled
self
.
_disabled
=
disabled
self
.
_disabled_reason
=
disabled_reason
self
.
_disabled_reason
=
disabled_reason
self
.
_boilerplate
=
boilerplate
@property
@property
def
category
(
self
):
def
category
(
self
):
...
@@ -371,6 +372,11 @@ class NestedXBlockSpec(object):
...
@@ -371,6 +372,11 @@ class NestedXBlockSpec(object):
"""
"""
return
self
.
_disabled_reason
return
self
.
_disabled_reason
@property
def
boilerplate
(
self
):
""" Boilerplate - if not None and not empty used as data-boilerplate attribute value """
return
self
.
_boilerplate
class
XBlockWithPreviewMixin
(
object
):
class
XBlockWithPreviewMixin
(
object
):
"""
"""
...
@@ -431,7 +437,13 @@ class StudioContainerWithNestedXBlocksMixin(StudioContainerXBlockMixin):
...
@@ -431,7 +437,13 @@ class StudioContainerWithNestedXBlocksMixin(StudioContainerXBlockMixin):
"""
"""
fragment
=
Fragment
()
fragment
=
Fragment
()
if
'wrap_children'
in
context
:
fragment
.
add_content
(
context
[
'wrap_children'
][
'head'
])
self
.
render_children
(
context
,
fragment
,
can_reorder
=
True
,
can_add
=
False
)
self
.
render_children
(
context
,
fragment
,
can_reorder
=
True
,
can_add
=
False
)
if
'wrap_children'
in
context
:
fragment
.
add_content
(
context
[
'wrap_children'
][
'tail'
])
fragment
.
add_content
(
fragment
.
add_content
(
loader
.
render_template
(
'templates/add_buttons.html'
,
{
'child_blocks'
:
self
.
get_nested_blocks_spec
()})
loader
.
render_template
(
'templates/add_buttons.html'
,
{
'child_blocks'
:
self
.
get_nested_blocks_spec
()})
)
)
...
...
xblockutils/templates/add_buttons.html
View file @
3b58c757
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
{%
if
block_spec
.
disabled
%}
{%
if
block_spec
.
disabled
%}
disabled=
"disabled"
title=
"{{ block_spec.disabled_reason }}"
disabled=
"disabled"
title=
"{{ block_spec.disabled_reason }}"
{%
endif
%}
{%
endif
%}
{%
if
block_spec
.
boilerplate
%}
data-boilerplate=
"{{ block_spec.boilerplate }}"
{%
endif
%}
>
>
{{ block_spec.label }}
{{ block_spec.label }}
</a>
</a>
...
...
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