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
3d2ca4f7
Commit
3d2ca4f7
authored
Jul 10, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deleting a private unit should remove it from the course
STUD-1962
parent
cb2422a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
27 deletions
+34
-27
common/lib/xmodule/xmodule/modulestore/mongo/draft.py
+6
-8
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+28
-18
common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py
+0
-1
No files found.
common/lib/xmodule/xmodule/modulestore/mongo/draft.py
View file @
3d2ca4f7
...
@@ -494,15 +494,13 @@ class DraftModuleStore(MongoModuleStore):
...
@@ -494,15 +494,13 @@ class DraftModuleStore(MongoModuleStore):
# Case 1: the draft item moved from one parent to another
# Case 1: the draft item moved from one parent to another
# Case 2: revision==ModuleStoreEnum.RevisionOption.all and the single parent has 2 versions: draft and published
# Case 2: revision==ModuleStoreEnum.RevisionOption.all and the single parent has 2 versions: draft and published
for
parent_location
in
parent_locations
:
for
parent_location
in
parent_locations
:
# don't remove from direct_only parent if other versions of this still exists
# don't remove from direct_only parent if other versions of this still exists (this code
# assumes that there's only one parent_location in this case)
if
not
is_item_direct_only
and
parent_location
.
category
in
DIRECT_ONLY_CATEGORIES
:
if
not
is_item_direct_only
and
parent_location
.
category
in
DIRECT_ONLY_CATEGORIES
:
# see if other version of root exists
# see if other version of to-be-deleted root exists
alt_location
=
location
.
replace
(
query
=
location
.
to_deprecated_son
(
prefix
=
'_id.'
)
revision
=
MongoRevisionKey
.
published
del
query
[
'_id.revision'
]
if
location
.
revision
==
MongoRevisionKey
.
draft
if
self
.
collection
.
find
(
query
)
.
count
()
>
1
:
else
MongoRevisionKey
.
draft
)
if
super
(
DraftModuleStore
,
self
)
.
has_item
(
alt_location
):
continue
continue
parent_block
=
super
(
DraftModuleStore
,
self
)
.
get_item
(
parent_location
)
parent_block
=
super
(
DraftModuleStore
,
self
)
.
get_item
(
parent_location
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
3d2ca4f7
...
@@ -332,30 +332,40 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
...
@@ -332,30 +332,40 @@ class TestMixedModuleStore(LocMapperSetupSansDjango):
self
.
store
.
get_item
(
self
.
writable_chapter_location
)
self
.
store
.
get_item
(
self
.
writable_chapter_location
)
# create and delete a private vertical with private children
# create and delete a private vertical with private children
private_vert
_loc
=
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
.
make_usage_key
(
'vertical'
,
'private'
)
private_vert
=
self
.
store
.
create_item
(
private_vert
=
self
.
store
.
create_and_save_xmodule
(
private_vert_loc
,
self
.
user_id
,
runtime
=
self
.
course
.
runtime
)
# don't use course_location as it may not be the repr
self
.
course
.
children
.
append
(
private_vert_loc
)
self
.
course_locations
[
self
.
MONGO_COURSEID
],
'vertical'
,
user_id
=
self
.
user_id
,
block_id
=
'private'
self
.
store
.
update_item
(
self
.
course
,
self
.
user_id
)
)
private_leaf
_loc
=
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
.
make_usage_key
(
'html'
,
'private_leaf'
)
private_leaf
=
self
.
store
.
create_item
(
self
.
store
.
create_and_save_xmodule
(
private_leaf_loc
,
self
.
user_id
,
runtime
=
self
.
course
.
runtime
)
# don't use course_location as it may not be the repr
private_vert
.
children
.
append
(
private_leaf_loc
)
private_vert
.
location
,
'html'
,
user_id
=
self
.
user_id
,
block_id
=
'private_leaf'
self
.
store
.
update_item
(
private_vert
,
self
.
user_id
)
)
# verify pre delete state (just to verify that the test is valid)
# verify pre delete state (just to verify that the test is valid)
self
.
assertTrue
(
hasattr
(
private_vert
,
'is_draft'
)
or
private_vert
.
location
.
branch
==
MongoRevisionKey
.
draft
)
self
.
assertTrue
(
hasattr
(
private_vert
,
'is_draft'
)
or
private_vert
.
location
.
branch
==
ModuleStoreEnum
.
BranchName
.
draft
)
self
.
assertIsNotNone
(
self
.
store
.
get_item
(
private_vert_loc
))
if
hasattr
(
private_vert
.
location
,
'version_guid'
):
self
.
assertIsNotNone
(
self
.
store
.
get_item
(
private_leaf_loc
))
# change to the HEAD version
vert_loc
=
private_vert
.
location
.
for_version
(
private_leaf
.
location
.
version_guid
)
else
:
vert_loc
=
private_vert
.
location
self
.
assertTrue
(
self
.
store
.
has_item
(
vert_loc
))
self
.
assertTrue
(
self
.
store
.
has_item
(
private_leaf
.
location
))
course
=
self
.
store
.
get_course
(
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
,
0
)
course
=
self
.
store
.
get_course
(
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
,
0
)
self
.
assertIn
(
private_
vert_loc
,
course
.
children
)
self
.
assertIn
(
vert_loc
,
course
.
children
)
# delete the vertical and ensure the course no longer points to it
# delete the vertical and ensure the course no longer points to it
self
.
store
.
delete_item
(
private_vert_loc
,
self
.
user_id
)
self
.
store
.
delete_item
(
vert_loc
,
self
.
user_id
)
with
self
.
assertRaises
(
ItemNotFoundError
):
self
.
store
.
get_item
(
private_vert_loc
)
with
self
.
assertRaises
(
ItemNotFoundError
):
self
.
store
.
get_item
(
private_leaf_loc
)
course
=
self
.
store
.
get_course
(
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
,
0
)
course
=
self
.
store
.
get_course
(
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
,
0
)
self
.
assertNotIn
(
private_vert_loc
,
course
.
children
)
if
hasattr
(
private_vert
.
location
,
'version_guid'
):
# change to the HEAD version
vert_loc
=
private_vert
.
location
.
for_version
(
course
.
location
.
version_guid
)
leaf_loc
=
private_leaf
.
location
.
for_version
(
course
.
location
.
version_guid
)
else
:
vert_loc
=
private_vert
.
location
leaf_loc
=
private_leaf
.
location
self
.
assertFalse
(
self
.
store
.
has_item
(
vert_loc
))
self
.
assertFalse
(
self
.
store
.
has_item
(
leaf_loc
))
self
.
assertNotIn
(
vert_loc
,
course
.
children
)
@ddt.data
(
'draft'
,
'split'
)
@ddt.data
(
'draft'
,
'split'
)
def
test_get_courses
(
self
,
default_ms
):
def
test_get_courses
(
self
,
default_ms
):
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py
View file @
3d2ca4f7
...
@@ -10,7 +10,6 @@ from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore
...
@@ -10,7 +10,6 @@ from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore
from
xmodule.modulestore.mongo
import
MongoModuleStore
,
DraftMongoModuleStore
from
xmodule.modulestore.mongo
import
MongoModuleStore
,
DraftMongoModuleStore
from
xmodule.modulestore.mongo.draft
import
DIRECT_ONLY_CATEGORIES
from
xmodule.modulestore.mongo.draft
import
DIRECT_ONLY_CATEGORIES
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
mock
import
Mock
class
SplitWMongoCourseBoostrapper
(
unittest
.
TestCase
):
class
SplitWMongoCourseBoostrapper
(
unittest
.
TestCase
):
...
...
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