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
bcae1c59
Commit
bcae1c59
authored
Dec 05, 2014
by
Adam Palay
Committed by
Zia Fazal
Apr 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't export draft children of orphaned drafted (TNL-923)
parent
862537cf
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
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
+13
-3
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
bcae1c59
...
@@ -260,6 +260,8 @@ class ImportRequiredTestCases(ContentStoreTestCase):
...
@@ -260,6 +260,8 @@ class ImportRequiredTestCases(ContentStoreTestCase):
# and assert that they contain the created modules
# and assert that they contain the created modules
self
.
assertIn
(
self
.
DRAFT_HTML
+
".xml"
,
draft_dir
.
listdir
(
'html'
))
self
.
assertIn
(
self
.
DRAFT_HTML
+
".xml"
,
draft_dir
.
listdir
(
'html'
))
self
.
assertIn
(
self
.
DRAFT_VIDEO
+
".xml"
,
draft_dir
.
listdir
(
'video'
))
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
# check for grading_policy.json
filesystem
=
OSFS
(
root_dir
/
'test_export/policies/2012_Fall'
)
filesystem
=
OSFS
(
root_dir
/
'test_export/policies/2012_Fall'
)
...
...
cms/djangoapps/contentstore/tests/utils.py
View file @
bcae1c59
...
@@ -138,6 +138,8 @@ class CourseTestCase(ModuleStoreTestCase):
...
@@ -138,6 +138,8 @@ class CourseTestCase(ModuleStoreTestCase):
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
TEST_VERTICAL
=
'vertical_test'
TEST_VERTICAL
=
'vertical_test'
ORPHAN_DRAFT_VERTICAL
=
'orphan_draft_vertical'
ORPHAN_DRAFT_HTML
=
'orphan_draft_html'
PRIVATE_VERTICAL
=
'a_private_vertical'
PRIVATE_VERTICAL
=
'a_private_vertical'
PUBLISHED_VERTICAL
=
'a_published_vertical'
PUBLISHED_VERTICAL
=
'a_published_vertical'
SEQUENTIAL
=
'vertical_sequential'
SEQUENTIAL
=
'vertical_sequential'
...
@@ -162,6 +164,18 @@ class CourseTestCase(ModuleStoreTestCase):
...
@@ -162,6 +164,18 @@ class CourseTestCase(ModuleStoreTestCase):
self
.
assertEqual
(
orphan_vertical
.
location
.
name
,
'no_references'
)
self
.
assertEqual
(
orphan_vertical
.
location
.
name
,
'no_references'
)
self
.
assertEqual
(
len
(
orphan_vertical
.
children
),
len
(
vertical
.
children
))
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
# create a Draft vertical
vertical
=
self
.
store
.
get_item
(
course_id
.
make_usage_key
(
'vertical'
,
self
.
TEST_VERTICAL
),
depth
=
1
)
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
)
draft_vertical
=
self
.
store
.
convert_to_draft
(
vertical
.
location
,
self
.
user
.
id
)
...
...
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
View file @
bcae1c59
...
@@ -131,15 +131,18 @@ def export_to_xml(modulestore, contentstore, course_key, root_dir, course_dir):
...
@@ -131,15 +131,18 @@ def export_to_xml(modulestore, contentstore, course_key, root_dir, course_dir):
draft_module
.
location
,
draft_module
.
location
,
revision
=
ModuleStoreEnum
.
RevisionOption
.
draft_preferred
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
:
if
parent_loc
is
not
None
:
logging
.
debug
(
'parent_loc = {0}'
.
format
(
parent_loc
))
parent_url
=
parent_loc
.
to_deprecated_string
()
draft_node
=
draft_node_constructor
(
draft_node
=
draft_node_constructor
(
draft_module
,
draft_module
,
location
=
draft_module
.
location
,
location
=
draft_module
.
location
,
url
=
draft_module
.
location
.
to_deprecated_string
(),
url
=
draft_module
.
location
.
to_deprecated_string
(),
parent_location
=
parent_loc
,
parent_location
=
parent_loc
,
parent_url
=
parent_loc
.
to_deprecated_string
()
,
parent_url
=
parent_url
,
)
)
draft_node_list
.
append
(
draft_node
)
draft_node_list
.
append
(
draft_node
)
...
@@ -153,6 +156,13 @@ def export_to_xml(modulestore, contentstore, course_key, root_dir, course_dir):
...
@@ -153,6 +156,13 @@ def export_to_xml(modulestore, contentstore, course_key, root_dir, course_dir):
if
not
hasattr
(
draft_node
.
module
,
'xml_attributes'
):
if
not
hasattr
(
draft_node
.
module
,
'xml_attributes'
):
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
draft_node
.
module
.
xml_attributes
[
'parent_url'
]
=
draft_node
.
parent_url
parent
=
modulestore
.
get_item
(
draft_node
.
parent_location
)
parent
=
modulestore
.
get_item
(
draft_node
.
parent_location
)
index
=
parent
.
children
.
index
(
draft_node
.
module
.
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