Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
3093efc8
Commit
3093efc8
authored
11 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Make bok-choy correctly publish units with children
parent
1bf5d712
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cms/djangoapps/contentstore/views/item.py
+10
-1
10 additions, 1 deletion
cms/djangoapps/contentstore/views/item.py
common/test/acceptance/fixtures/course.py
+40
-31
40 additions, 31 deletions
common/test/acceptance/fixtures/course.py
with
50 additions
and
32 deletions
cms/djangoapps/contentstore/views/item.py
+
10
−
1
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.
...
...
This diff is collapsed.
Click to expand it.
common/test/acceptance/fixtures/course.py
+
40
−
31
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
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment