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
2ca1d0ef
Commit
2ca1d0ef
authored
Jun 12, 2015
by
Syed Hassan Raza
Committed by
Adam Palay
Jun 25, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the source_version xblock after discard changes
formatting changes
parent
4b643164
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 @
2ca1d0ef
...
@@ -1875,6 +1875,11 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
...
@@ -1875,6 +1875,11 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
block_data
.
fields
=
settings
block_data
.
fields
=
settings
new_id
=
new_structure
[
'_id'
]
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
.
version_block
(
block_data
,
user_id
,
new_id
)
self
.
update_structure
(
course_key
,
new_structure
)
self
.
update_structure
(
course_key
,
new_structure
)
# update the index entry if appropriate
# update the index entry if appropriate
...
@@ -2969,8 +2974,11 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
...
@@ -2969,8 +2974,11 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
if
getattr
(
destination_block
.
edit_info
,
key
)
is
None
:
if
getattr
(
destination_block
.
edit_info
,
key
)
is
None
:
setattr
(
destination_block
.
edit_info
,
key
,
val
)
setattr
(
destination_block
.
edit_info
,
key
,
val
)
# introduce new edit info field for tracing where copied/published blocks came
# If the block we are copying from was itself a copy, then just
destination_block
.
edit_info
.
source_version
=
new_block
.
edit_info
.
update_version
# 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
:
if
blacklist
!=
EXCLUDE_ALL
:
for
child
in
destination_block
.
fields
.
get
(
'children'
,
[]):
for
child
in
destination_block
.
fields
.
get
(
'children'
,
[]):
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
2ca1d0ef
...
@@ -523,6 +523,75 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
...
@@ -523,6 +523,75 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
component
=
self
.
store
.
publish
(
component
.
location
,
self
.
user_id
)
component
=
self
.
store
.
publish
(
component
.
location
,
self
.
user_id
)
self
.
assertFalse
(
self
.
store
.
has_changes
(
component
))
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
):
def
setup_has_changes
(
self
,
default_ms
):
"""
"""
Common set up for has_changes tests below.
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