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
e900a47b
Commit
e900a47b
authored
Aug 06, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide workarounds for skip_draft where other code doesn't want its behavior
parent
5fc30dc4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
6 deletions
+29
-6
cms/djangoapps/contentstore/tests/utils.py
+8
-1
common/lib/xmodule/xmodule/modulestore/split_migrator.py
+2
-0
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+7
-2
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
+12
-3
No files found.
cms/djangoapps/contentstore/tests/utils.py
View file @
e900a47b
...
@@ -247,7 +247,14 @@ class CourseTestCase(ModuleStoreTestCase):
...
@@ -247,7 +247,14 @@ class CourseTestCase(ModuleStoreTestCase):
course1_items
=
self
.
store
.
get_items
(
course1_id
)
course1_items
=
self
.
store
.
get_items
(
course1_id
)
course2_items
=
self
.
store
.
get_items
(
course2_id
)
course2_items
=
self
.
store
.
get_items
(
course2_id
)
self
.
assertGreater
(
len
(
course1_items
),
0
)
# ensure it found content instead of [] == []
self
.
assertGreater
(
len
(
course1_items
),
0
)
# ensure it found content instead of [] == []
self
.
assertEqual
(
len
(
course1_items
),
len
(
course2_items
))
if
len
(
course1_items
)
!=
len
(
course2_items
):
course1_block_ids
=
set
([
item
.
location
.
block_id
for
item
in
course1_items
])
course2_block_ids
=
set
([
item
.
location
.
block_id
for
item
in
course2_items
])
raise
AssertionError
(
u"Course1 extra blocks: {}; course2 extra blocks: {}"
.
format
(
course1_block_ids
-
course2_block_ids
,
course2_block_ids
-
course1_block_ids
)
)
for
course1_item
in
course1_items
:
for
course1_item
in
course1_items
:
course2_item_location
=
course1_item
.
location
.
map_into_course
(
course2_id
)
course2_item_location
=
course1_item
.
location
.
map_into_course
(
course2_id
)
...
...
common/lib/xmodule/xmodule/modulestore/split_migrator.py
View file @
e900a47b
...
@@ -62,6 +62,7 @@ class SplitMigrator(object):
...
@@ -62,6 +62,7 @@ class SplitMigrator(object):
new_org
,
new_course
,
new_run
,
user_id
,
new_org
,
new_course
,
new_run
,
user_id
,
fields
=
new_fields
,
fields
=
new_fields
,
master_branch
=
ModuleStoreEnum
.
BranchName
.
published
,
master_branch
=
ModuleStoreEnum
.
BranchName
.
published
,
skip_auto_publish
=
True
,
**
kwargs
**
kwargs
)
)
...
@@ -101,6 +102,7 @@ class SplitMigrator(object):
...
@@ -101,6 +102,7 @@ class SplitMigrator(object):
module
,
course_version_locator
,
new_course
.
location
.
block_id
module
,
course_version_locator
,
new_course
.
location
.
block_id
),
),
continue_version
=
True
,
continue_version
=
True
,
skip_auto_publish
=
True
,
**
kwargs
**
kwargs
)
)
# after done w/ published items, add version for DRAFT pointing to the published structure
# after done w/ published items, add version for DRAFT pointing to the published structure
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
e900a47b
...
@@ -953,8 +953,13 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -953,8 +953,13 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
if
source_index
is
None
:
if
source_index
is
None
:
raise
ItemNotFoundError
(
"Cannot find a course at {0}. Aborting"
.
format
(
source_course_id
))
raise
ItemNotFoundError
(
"Cannot find a course at {0}. Aborting"
.
format
(
source_course_id
))
return
self
.
create_course
(
return
self
.
create_course
(
dest_course_id
.
org
,
dest_course_id
.
course
,
dest_course_id
.
run
,
user_id
,
fields
=
fields
,
dest_course_id
.
org
,
dest_course_id
.
course
,
dest_course_id
.
run
,
versions_dict
=
source_index
[
'versions'
],
search_targets
=
source_index
[
'search_targets'
],
**
kwargs
user_id
,
fields
=
fields
,
versions_dict
=
source_index
[
'versions'
],
search_targets
=
source_index
[
'search_targets'
],
skip_auto_publish
=
True
,
**
kwargs
)
)
def
create_course
(
def
create_course
(
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
View file @
e900a47b
...
@@ -15,7 +15,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
...
@@ -15,7 +15,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
A subclass of Split that supports a dual-branch fall-back versioning framework
A subclass of Split that supports a dual-branch fall-back versioning framework
with a Draft branch that falls back to a Published branch.
with a Draft branch that falls back to a Published branch.
"""
"""
def
create_course
(
self
,
org
,
course
,
run
,
user_id
,
**
kwargs
):
def
create_course
(
self
,
org
,
course
,
run
,
user_id
,
skip_auto_publish
=
False
,
**
kwargs
):
"""
"""
Creates and returns the course.
Creates and returns the course.
...
@@ -32,10 +32,14 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
...
@@ -32,10 +32,14 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_course
(
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_course
(
org
,
course
,
run
,
user_id
,
master_branch
=
master_branch
,
**
kwargs
org
,
course
,
run
,
user_id
,
master_branch
=
master_branch
,
**
kwargs
)
)
if
master_branch
==
ModuleStoreEnum
.
BranchName
.
draft
and
not
skip_auto_publish
:
# any other value is hopefully only cloning or doing something which doesn't want this value add
self
.
_auto_publish_no_children
(
item
.
location
,
item
.
location
.
category
,
user_id
,
**
kwargs
)
self
.
_auto_publish_no_children
(
item
.
location
,
item
.
location
.
category
,
user_id
,
**
kwargs
)
# create any other necessary things as a side effect: ensure they populate the draft branch
# create any other necessary things as a side effect: ensure they populate the draft branch
# and rely on auto publish to populate the published branch
# and rely on auto publish to populate the published branch: split's create course doesn't
# call super b/c it needs the auto publish above to have happened before any of the create_items
# in this
with
self
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
item
.
id
):
with
self
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
item
.
id
):
super
(
SplitMongoModuleStore
,
self
)
.
create_course
(
super
(
SplitMongoModuleStore
,
self
)
.
create_course
(
org
,
course
,
run
,
user_id
,
**
kwargs
org
,
course
,
run
,
user_id
,
**
kwargs
...
@@ -84,14 +88,19 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
...
@@ -84,14 +88,19 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
def
create_item
(
def
create_item
(
self
,
user_id
,
course_key
,
block_type
,
block_id
=
None
,
self
,
user_id
,
course_key
,
block_type
,
block_id
=
None
,
definition_locator
=
None
,
fields
=
None
,
definition_locator
=
None
,
fields
=
None
,
force
=
False
,
continue_version
=
False
,
**
kwargs
force
=
False
,
continue_version
=
False
,
skip_auto_publish
=
False
,
**
kwargs
):
):
"""
Adds skip_auto_publish to behavior or parent. Skip_auto_publish basically just calls the super
and skips all of this wrapper's functionality.
"""
course_key
=
self
.
_map_revision_to_branch
(
course_key
)
course_key
=
self
.
_map_revision_to_branch
(
course_key
)
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_item
(
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_item
(
user_id
,
course_key
,
block_type
,
block_id
=
block_id
,
user_id
,
course_key
,
block_type
,
block_id
=
block_id
,
definition_locator
=
definition_locator
,
fields
=
fields
,
definition_locator
=
definition_locator
,
fields
=
fields
,
force
=
force
,
continue_version
=
continue_version
,
**
kwargs
force
=
force
,
continue_version
=
continue_version
,
**
kwargs
)
)
if
not
skip_auto_publish
:
self
.
_auto_publish_no_children
(
item
.
location
,
item
.
location
.
category
,
user_id
,
**
kwargs
)
self
.
_auto_publish_no_children
(
item
.
location
,
item
.
location
.
category
,
user_id
,
**
kwargs
)
return
item
return
item
...
...
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