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
27c710b8
Commit
27c710b8
authored
Dec 05, 2014
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't export draft children of orphaned drafted (TNL-923)
parent
72dbeb7f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
10 deletions
+36
-10
cms/djangoapps/contentstore/tests/test_contentstore.py
+2
-0
cms/djangoapps/contentstore/tests/utils.py
+14
-0
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
+20
-10
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
27c710b8
...
...
@@ -258,6 +258,8 @@ class ImportRequiredTestCases(ContentStoreTestCase):
# and assert that they contain the created modules
self
.
assertIn
(
self
.
DRAFT_HTML
+
".xml"
,
draft_dir
.
listdir
(
'html'
))
self
.
assertIn
(
self
.
DRAFT_VIDEO
+
".xml"
,
draft_dir
.
listdir
(
'video'
))
# and assert the child of the orphaned draft wasn't exported
self
.
assertNotIn
(
self
.
ORPHAN_DRAFT_HTML
+
".xml"
,
draft_dir
.
listdir
(
'html'
))
# check for grading_policy.json
filesystem
=
OSFS
(
root_dir
/
'test_export/policies/2012_Fall'
)
...
...
cms/djangoapps/contentstore/tests/utils.py
View file @
27c710b8
...
...
@@ -134,6 +134,8 @@ class CourseTestCase(ModuleStoreTestCase):
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
TEST_VERTICAL
=
'vertical_test'
ORPHAN_DRAFT_VERTICAL
=
'orphan_draft_vertical'
ORPHAN_DRAFT_HTML
=
'orphan_draft_html'
PRIVATE_VERTICAL
=
'a_private_vertical'
PUBLISHED_VERTICAL
=
'a_published_vertical'
SEQUENTIAL
=
'vertical_sequential'
...
...
@@ -158,6 +160,18 @@ class CourseTestCase(ModuleStoreTestCase):
self
.
assertEqual
(
orphan_vertical
.
location
.
name
,
'no_references'
)
self
.
assertEqual
(
len
(
orphan_vertical
.
children
),
len
(
vertical
.
children
))
# create an orphan vertical and html; we already don't try to import
# the orphaned vertical, but we should make sure we don't import
# the orphaned vertical's child html, too
orphan_draft_vertical
=
self
.
store
.
create_item
(
self
.
user
.
id
,
course_id
,
'vertical'
,
self
.
ORPHAN_DRAFT_VERTICAL
)
orphan_draft_html
=
self
.
store
.
create_item
(
self
.
user
.
id
,
course_id
,
'html'
,
self
.
ORPHAN_DRAFT_HTML
)
orphan_draft_vertical
.
children
.
append
(
orphan_draft_html
.
location
)
self
.
store
.
update_item
(
orphan_draft_vertical
,
self
.
user
.
id
)
# create a Draft vertical
vertical
=
self
.
store
.
get_item
(
course_id
.
make_usage_key
(
'vertical'
,
self
.
TEST_VERTICAL
),
depth
=
1
)
draft_vertical
=
self
.
store
.
convert_to_draft
(
vertical
.
location
,
self
.
user
.
id
)
...
...
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
View file @
27c710b8
...
...
@@ -131,18 +131,21 @@ def export_to_xml(modulestore, contentstore, course_key, root_dir, course_dir):
draft_module
.
location
,
revision
=
ModuleStoreEnum
.
RevisionOption
.
draft_preferred
)
# Don't try to export orphaned items.
# if module has no parent, set its parent_url to `None`
parent_url
=
None
if
parent_loc
is
not
None
:
logging
.
debug
(
'parent_loc = {0}'
.
format
(
parent_loc
))
draft_node
=
draft_node_constructor
(
draft_module
,
location
=
draft_module
.
location
,
url
=
draft_module
.
location
.
to_deprecated_string
(),
parent_location
=
parent_loc
,
parent_url
=
parent_loc
.
to_deprecated_string
(),
)
parent_url
=
parent_loc
.
to_deprecated_string
()
draft_node
=
draft_node_constructor
(
draft_module
,
location
=
draft_module
.
location
,
url
=
draft_module
.
location
.
to_deprecated_string
(),
parent_location
=
parent_loc
,
parent_url
=
parent_url
,
)
draft_node_list
.
append
(
draft_node
)
draft_node_list
.
append
(
draft_node
)
for
draft_node
in
get_draft_subtree_roots
(
draft_node_list
):
# only export the roots of the draft subtrees
...
...
@@ -153,6 +156,13 @@ def export_to_xml(modulestore, contentstore, course_key, root_dir, course_dir):
if
not
hasattr
(
draft_node
.
module
,
'xml_attributes'
):
draft_node
.
module
.
xml_attributes
=
{}
# Don't try to export orphaned items
# and their descendents
if
draft_node
.
parent_location
is
None
:
continue
logging
.
debug
(
'parent_loc = {0}'
.
format
(
draft_node
.
parent_location
))
draft_node
.
module
.
xml_attributes
[
'parent_url'
]
=
draft_node
.
parent_url
parent
=
modulestore
.
get_item
(
draft_node
.
parent_location
)
index
=
parent
.
children
.
index
(
draft_node
.
module
.
location
)
...
...
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