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
3093efc8
Commit
3093efc8
authored
Feb 21, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make bok-choy correctly publish units with children
parent
1bf5d712
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
32 deletions
+50
-32
cms/djangoapps/contentstore/views/item.py
+10
-1
common/test/acceptance/fixtures/course.py
+40
-31
No files found.
cms/djangoapps/contentstore/views/item.py
View file @
3093efc8
...
...
@@ -316,9 +316,18 @@ def _save_item(request, usage_loc, item_location, data=None, children=None, meta
# Make public after updating the xblock, in case the caller asked
# for both an update and a publish.
if
publish
and
publish
==
'make_public'
:
def
_publish
(
block
):
# This is super gross, but prevents us from publishing something that
# we shouldn't. Ideally, all modulestores would have a consistant
# interface for publishing. However, as of now, only the DraftMongoModulestore
# does, so we have to check for the attribute explicitly.
store
=
get_modulestore
(
block
.
location
)
if
hasattr
(
store
,
'publish'
):
store
.
publish
(
block
.
location
,
request
.
user
.
id
)
_xmodule_recurse
(
existing_item
,
lambda
i
:
modulestore
()
.
publish
(
i
.
location
,
request
.
user
.
id
)
_publish
)
# Note that children aren't being returned until we have a use case.
...
...
common/test/acceptance/fixtures/course.py
View file @
3093efc8
...
...
@@ -95,31 +95,20 @@ class XBlockFixtureDesc(object):
self
.
children
.
extend
(
args
)
return
self
def
serialize
(
self
,
parent_loc
=
None
):
def
serialize
(
self
):
"""
Return a JSON representation of the XBlock, suitable
for sending as POST data to /xblock
XBlocks are always set to public visibility.
"""
payload
=
{
'category'
:
self
.
category
,
return
json
.
dumps
({
'display_name'
:
self
.
display_name
,
'data'
:
self
.
data
,
'metadata'
:
self
.
metadata
,
'grader
_t
ype'
:
self
.
grader_type
,
'grader
T
ype'
:
self
.
grader_type
,
'publish'
:
self
.
publish
}
# Need to handle detached categories differently, since they are not published
# This may change in the future.
if
self
.
category
in
[
'static_tab'
]:
del
payload
[
'publish'
]
if
parent_loc
is
not
None
:
payload
[
'parent_locator'
]
=
parent_loc
return
json
.
dumps
(
payload
)
})
def
__str__
(
self
):
"""
...
...
@@ -395,15 +384,25 @@ class CourseFixture(StudioApiFixture):
loc
=
self
.
_create_xblock
(
parent_loc
,
desc
)
self
.
_create_xblock_children
(
loc
,
desc
.
children
)
self
.
_publish_xblock
(
parent_loc
)
def
_create_xblock
(
self
,
parent_loc
,
xblock_desc
):
"""
Create an XBlock with `parent_loc` (the location of the parent block)
and `xblock_desc` (an `XBlockFixtureDesc` instance).
"""
create_payload
=
{
'category'
:
xblock_desc
.
category
,
'display_name'
:
xblock_desc
.
display_name
,
}
if
parent_loc
is
not
None
:
create_payload
[
'parent_locator'
]
=
parent_loc
# Create the new XBlock
response
=
self
.
session
.
post
(
STUDIO_BASE_URL
+
'/xblock'
,
data
=
xblock_desc
.
serialize
(
parent_loc
=
parent_loc
),
data
=
json
.
dumps
(
create_payload
),
headers
=
self
.
headers
,
)
...
...
@@ -417,24 +416,34 @@ class CourseFixture(StudioApiFixture):
except
ValueError
:
raise
CourseFixtureError
(
"Could not decode JSON from '{0}'"
.
format
(
response
.
content
))
if
loc
is
not
None
:
# Configure the XBlock
response
=
self
.
session
.
post
(
STUDIO_BASE_URL
+
'/xblock/'
+
loc
,
data
=
xblock_desc
.
serialize
(),
headers
=
self
.
headers
,
)
# Configure the XBlock
re
sponse
=
self
.
session
.
post
(
STUDIO_BASE_URL
+
'/xblock/'
+
loc
,
data
=
xblock_desc
.
serialize
(),
headers
=
self
.
headers
,
)
if
response
.
ok
:
re
turn
loc
else
:
raise
CourseFixtureError
(
"Could not update {0}. Status code: {1}"
.
format
(
xblock_desc
,
response
.
status_code
)
)
if
response
.
ok
:
return
loc
else
:
raise
CourseFixtureError
(
"Could not update {0}. Status code: {1}"
.
format
(
xblock_desc
,
response
.
status_code
))
def
_publish_xblock
(
self
,
locator
):
"""
Publish the xblock at `locator`.
"""
# Create the new XBlock
response
=
self
.
session
.
put
(
"{}/xblock/{}"
.
format
(
STUDIO_BASE_URL
,
locator
),
data
=
json
.
dumps
({
'publish'
:
'make_public'
}),
headers
=
self
.
headers
,
)
else
:
raise
CourseFixtureError
(
"Could not retrieve location of {0}"
.
format
(
xblock_desc
))
if
not
response
.
ok
:
msg
=
"Could not publish {}. Status was {}"
.
format
(
locator
,
response
.
status_code
)
raise
CourseFixtureError
(
msg
)
def
_encode_post_dict
(
self
,
post_dict
):
"""
...
...
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