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
d4b60991
Commit
d4b60991
authored
Nov 21, 2014
by
Don Mitchell
Committed by
Zia Fazal
Apr 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Imports must replace drafts w/ published in split
PLAT-299
parent
8bb8981b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
13 deletions
+53
-13
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
+4
-12
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+49
-1
No files found.
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
View file @
d4b60991
...
@@ -416,20 +416,12 @@ class DraftVersioningModuleStore(SplitMongoModuleStore, ModuleStoreDraftAndPubli
...
@@ -416,20 +416,12 @@ class DraftVersioningModuleStore(SplitMongoModuleStore, ModuleStoreDraftAndPubli
new_usage_key
=
course_key
.
make_usage_key
(
block_type
,
block_id
)
new_usage_key
=
course_key
.
make_usage_key
(
block_type
,
block_id
)
if
self
.
get_branch_setting
()
==
ModuleStoreEnum
.
Branch
.
published_only
:
if
self
.
get_branch_setting
()
==
ModuleStoreEnum
.
Branch
.
published_only
:
#
if importing a direct only, override existing draft
#
override existing draft (PLAT-297, PLAT-299). NOTE: this has the effect of removing
if
block_type
in
DIRECT_ONLY_CATEGORIES
:
# any local changes w/ the import.
draft_course
=
course_key
.
for_branch
(
ModuleStoreEnum
.
BranchName
.
draft
)
draft_course
=
course_key
.
for_branch
(
ModuleStoreEnum
.
BranchName
.
draft
)
with
self
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
draft_course
):
with
self
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
draft_course
):
draft
=
self
.
import_xblock
(
user_id
,
draft_course
,
block_type
,
block_id
,
fields
,
runtime
)
draft_block
=
self
.
import_xblock
(
user_id
,
draft_course
,
block_type
,
block_id
,
fields
,
runtime
)
self
.
_auto_publish_no_children
(
draft
.
location
,
block_type
,
user_id
)
return
self
.
publish
(
draft_block
.
location
.
version_agnostic
(),
user_id
,
blacklist
=
EXCLUDE_ALL
,
**
kwargs
)
return
self
.
get_item
(
new_usage_key
.
for_branch
(
ModuleStoreEnum
.
BranchName
.
published
))
# check whether it's new to draft (PLAT_297, need to check even if not new to pub)
elif
not
self
.
has_item
(
new_usage_key
.
for_branch
(
ModuleStoreEnum
.
BranchName
.
draft
)):
# add to draft too
draft_course
=
course_key
.
for_branch
(
ModuleStoreEnum
.
BranchName
.
draft
)
with
self
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
draft_course
):
draft
=
self
.
import_xblock
(
user_id
,
draft_course
,
block_type
,
block_id
,
fields
,
runtime
)
return
self
.
publish
(
draft
.
location
,
user_id
,
blacklist
=
EXCLUDE_ALL
)
# do the import
# do the import
partitioned_fields
=
self
.
partition_fields_by_scope
(
block_type
,
fields
)
partitioned_fields
=
self
.
partition_fields_by_scope
(
block_type
,
fields
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
d4b60991
...
@@ -23,6 +23,7 @@ from xmodule.contentstore.content import StaticContent
...
@@ -23,6 +23,7 @@ from xmodule.contentstore.content import StaticContent
import
mimetypes
import
mimetypes
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
nose
import
SkipTest
if
not
settings
.
configured
:
if
not
settings
.
configured
:
settings
.
configure
()
settings
.
configure
()
...
@@ -1871,7 +1872,7 @@ class TestMixedModuleStore(CourseComparisonTest):
...
@@ -1871,7 +1872,7 @@ class TestMixedModuleStore(CourseComparisonTest):
self
.
assertCoursesEqual
(
source_store
,
source_course_key
,
dest_store
,
dest_course_id
)
self
.
assertCoursesEqual
(
source_store
,
source_course_key
,
dest_store
,
dest_course_id
)
@ddt.data
(
ModuleStoreEnum
.
Type
.
mongo
,
ModuleStoreEnum
.
Type
.
split
)
@ddt.data
(
ModuleStoreEnum
.
Type
.
mongo
,
ModuleStoreEnum
.
Type
.
split
)
def
test_import_
edit
_import
(
self
,
default
):
def
test_import_
delete
_import
(
self
,
default
):
"""
"""
Test that deleting an element after import and then re-importing restores that element in draft
Test that deleting an element after import and then re-importing restores that element in draft
as well as published branches (PLAT_297)
as well as published branches (PLAT_297)
...
@@ -1916,6 +1917,53 @@ class TestMixedModuleStore(CourseComparisonTest):
...
@@ -1916,6 +1917,53 @@ class TestMixedModuleStore(CourseComparisonTest):
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
published_only
,
course_id
):
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
published_only
,
course_id
):
self
.
assertTrue
(
self
.
store
.
has_item
(
vertical_loc
))
self
.
assertTrue
(
self
.
store
.
has_item
(
vertical_loc
))
@ddt.data
(
ModuleStoreEnum
.
Type
.
mongo
,
ModuleStoreEnum
.
Type
.
split
)
def
test_import_edit_import
(
self
,
default
):
"""
Test that editing an element after import and then re-importing resets the draft and pub'd
to the imported pub'd value (PLAT-299)
"""
if
default
==
ModuleStoreEnum
.
Type
.
mongo
:
raise
SkipTest
# set the default modulestore
with
MongoContentstoreBuilder
()
.
build
()
as
contentstore
:
self
.
store
=
MixedModuleStore
(
contentstore
=
contentstore
,
create_modulestore_instance
=
create_modulestore_instance
,
mappings
=
{},
**
self
.
OPTIONS
)
self
.
addCleanup
(
self
.
store
.
close_all_connections
)
with
self
.
store
.
default_store
(
default
):
dest_course_key
=
self
.
store
.
make_course_key
(
'a'
,
'course'
,
'course'
)
courses
=
import_from_xml
(
self
.
store
,
self
.
user_id
,
DATA_DIR
,
[
'toy'
],
load_error_modules
=
False
,
static_content_store
=
contentstore
,
target_course_id
=
dest_course_key
,
create_new_course_if_not_present
=
True
,
)
course_id
=
courses
[
0
]
.
id
# no need to verify course content here as test_cross_modulestore_import_export does that
# delete the vertical
vertical_loc
=
course_id
.
make_usage_key
(
'vertical'
,
'vertical_test'
)
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
course_id
):
vertical
=
self
.
store
.
get_item
(
vertical_loc
)
vertical
.
display_name
=
"4"
self
.
store
.
update_item
(
vertical
,
self
.
user_id
)
# now re-import
import_from_xml
(
self
.
store
,
self
.
user_id
,
DATA_DIR
,
[
'toy'
],
load_error_modules
=
False
,
static_content_store
=
contentstore
,
target_course_id
=
dest_course_key
,
)
# verify it's the same in both published and draft (toy has no drafts)
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
course_id
):
draft_vertical
=
self
.
store
.
get_item
(
vertical_loc
)
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
published_only
,
course_id
):
published_vertical
=
self
.
store
.
get_item
(
vertical_loc
)
self
.
assertEqual
(
draft_vertical
.
display_name
,
published_vertical
.
display_name
)
# ============================================================================================================
# ============================================================================================================
# General utils for not using django settings
# General utils for not using django settings
# ============================================================================================================
# ============================================================================================================
...
...
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