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
2de67bd3
Commit
2de67bd3
authored
Jun 26, 2015
by
Adam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8680 from edx/hotfix/2015-06-25
fix the source_version xblock after discard changes
parents
4b643164
2ca1d0ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
2 deletions
+79
-2
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+10
-2
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+69
-0
No files found.
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
2de67bd3
...
...
@@ -1875,6 +1875,11 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
block_data
.
fields
=
settings
new_id
=
new_structure
[
'_id'
]
# source_version records which revision a block was copied from. In this method, we're updating
# the block, so it's no longer a direct copy, and we can remove the source_version reference.
block_data
.
edit_info
.
source_version
=
None
self
.
version_block
(
block_data
,
user_id
,
new_id
)
self
.
update_structure
(
course_key
,
new_structure
)
# update the index entry if appropriate
...
...
@@ -2969,8 +2974,11 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
if
getattr
(
destination_block
.
edit_info
,
key
)
is
None
:
setattr
(
destination_block
.
edit_info
,
key
,
val
)
# introduce new edit info field for tracing where copied/published blocks came
destination_block
.
edit_info
.
source_version
=
new_block
.
edit_info
.
update_version
# If the block we are copying from was itself a copy, then just
# reference the original source, rather than the copy.
destination_block
.
edit_info
.
source_version
=
(
new_block
.
edit_info
.
source_version
or
new_block
.
edit_info
.
update_version
)
if
blacklist
!=
EXCLUDE_ALL
:
for
child
in
destination_block
.
fields
.
get
(
'children'
,
[]):
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
2de67bd3
...
...
@@ -523,6 +523,75 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
component
=
self
.
store
.
publish
(
component
.
location
,
self
.
user_id
)
self
.
assertFalse
(
self
.
store
.
has_changes
(
component
))
@ddt.data
(
'draft'
,
'split'
)
def
test_unit_stuck_in_draft_mode
(
self
,
default_ms
):
"""
After revert_to_published() the has_changes() should return false if draft has no changes
"""
self
.
initdb
(
default_ms
)
test_course
=
self
.
store
.
create_course
(
'testx'
,
'GreekHero'
,
'test_run'
,
self
.
user_id
)
# Create a dummy component to test against
xblock
=
self
.
store
.
create_item
(
self
.
user_id
,
test_course
.
id
,
'vertical'
,
block_id
=
'test_vertical'
)
# Not yet published, so changes are present
self
.
assertTrue
(
self
.
store
.
has_changes
(
xblock
))
# Publish and verify that there are no unpublished changes
component
=
self
.
store
.
publish
(
xblock
.
location
,
self
.
user_id
)
self
.
assertFalse
(
self
.
store
.
has_changes
(
component
))
self
.
store
.
revert_to_published
(
component
.
location
,
self
.
user_id
)
component
=
self
.
store
.
get_item
(
component
.
location
)
self
.
assertFalse
(
self
.
store
.
has_changes
(
component
))
# Publish and verify again
component
=
self
.
store
.
publish
(
component
.
location
,
self
.
user_id
)
self
.
assertFalse
(
self
.
store
.
has_changes
(
component
))
@ddt.data
(
'draft'
,
'split'
)
def
test_unit_stuck_in_published_mode
(
self
,
default_ms
):
"""
After revert_to_published() the has_changes() should return true if draft has changes
"""
self
.
initdb
(
default_ms
)
test_course
=
self
.
store
.
create_course
(
'testx'
,
'GreekHero'
,
'test_run'
,
self
.
user_id
)
# Create a dummy component to test against
xblock
=
self
.
store
.
create_item
(
self
.
user_id
,
test_course
.
id
,
'vertical'
,
block_id
=
'test_vertical'
)
# Not yet published, so changes are present
self
.
assertTrue
(
self
.
store
.
has_changes
(
xblock
))
# Publish and verify that there are no unpublished changes
component
=
self
.
store
.
publish
(
xblock
.
location
,
self
.
user_id
)
self
.
assertFalse
(
self
.
store
.
has_changes
(
component
))
# Discard changes and verify that there are no changes
self
.
store
.
revert_to_published
(
component
.
location
,
self
.
user_id
)
component
=
self
.
store
.
get_item
(
component
.
location
)
self
.
assertFalse
(
self
.
store
.
has_changes
(
component
))
# Change the component, then check that there now are changes
component
=
self
.
store
.
get_item
(
component
.
location
)
component
.
display_name
=
'Changed Display Name'
self
.
store
.
update_item
(
component
,
self
.
user_id
)
# Verify that changes are present
self
.
assertTrue
(
self
.
store
.
has_changes
(
component
))
def
setup_has_changes
(
self
,
default_ms
):
"""
Common set up for has_changes tests below.
...
...
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