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
3f8a2f03
Commit
3f8a2f03
authored
Sep 13, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a setter to make editing location possible
parent
9d6c104f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
28 deletions
+24
-28
cms/djangoapps/contentstore/tests/test_contentstore.py
+5
-7
common/lib/xmodule/xmodule/modulestore/mongo/draft.py
+1
-1
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+2
-10
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+2
-10
common/lib/xmodule/xmodule/x_module.py
+14
-0
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
3f8a2f03
...
...
@@ -351,7 +351,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
def
test_create_static_tab_and_rename
(
self
):
module_store
=
modulestore
(
'direct'
)
CourseFactory
.
create
(
org
=
'edX'
,
course
=
'999'
,
display_name
=
'Robot Super Course'
)
course_location
=
Location
([
'i4x'
,
'edX'
,
'999'
,
'course'
,
'Robot_Super_Course'
,
None
])
course_location
=
Location
([
'i4x'
,
'edX'
,
'999'
,
'course'
,
'Robot_Super_Course'
,
None
])
item
=
ItemFactory
.
create
(
parent_location
=
course_location
,
category
=
'static_tab'
,
display_name
=
"My Tab"
)
...
...
@@ -733,7 +733,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
# we want to assert equality between the objects, but we know the locations
# differ, so just make them equal for testing purposes
source_item
.
scope_ids
=
source_item
.
scope_ids
.
_replace
(
def_id
=
new_loc
,
usage_id
=
new_loc
)
source_item
.
location
=
new_loc
if
hasattr
(
source_item
,
'data'
)
and
hasattr
(
lookup_item
,
'data'
):
self
.
assertEqual
(
source_item
.
data
,
lookup_item
.
data
)
...
...
@@ -914,8 +914,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
depth
=
1
)
# We had a bug where orphaned draft nodes caused export to fail. This is here to cover that case.
draft_loc
=
mongo
.
draft
.
as_draft
(
vertical
.
location
.
replace
(
name
=
'no_references'
))
vertical
.
scope_ids
=
vertical
.
scope_ids
.
_replace
(
def_id
=
draft_loc
,
usage_id
=
draft_loc
)
vertical
.
location
=
mongo
.
draft
.
as_draft
(
vertical
.
location
.
replace
(
name
=
'no_references'
))
draft_store
.
save_xmodule
(
vertical
)
orphan_vertical
=
draft_store
.
get_item
(
vertical
.
location
)
...
...
@@ -933,8 +932,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
root_dir
=
path
(
mkdtemp_clean
())
# now create a new/different private (draft only) vertical
draft_loc
=
mongo
.
draft
.
as_draft
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
'vertical'
,
'a_private_vertical'
,
None
]))
vertical
.
scope_ids
=
vertical
.
scope_ids
.
_replace
(
def_id
=
draft_loc
,
usage_id
=
draft_loc
)
vertical
.
location
=
mongo
.
draft
.
as_draft
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
'vertical'
,
'a_private_vertical'
,
None
]))
draft_store
.
save_xmodule
(
vertical
)
private_vertical
=
draft_store
.
get_item
(
vertical
.
location
)
vertical
=
None
# blank out b/c i destructively manipulated its location 2 lines above
...
...
@@ -983,7 +981,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertEqual
(
on_disk
[
'course/2012_Fall'
],
own_metadata
(
course
))
# remove old course
delete_course
(
module_store
,
content_store
,
location
)
delete_course
(
module_store
,
content_store
,
location
,
commit
=
True
)
# reimport
import_from_xml
(
module_store
,
root_dir
,
[
'test_export'
],
draft_store
=
draft_store
)
...
...
common/lib/xmodule/xmodule/modulestore/mongo/draft.py
View file @
3f8a2f03
...
...
@@ -42,7 +42,7 @@ def wrap_draft(item):
non-draft location in either case
"""
setattr
(
item
,
'is_draft'
,
item
.
location
.
revision
==
DRAFT
)
item
.
scope_ids
=
item
.
scope_ids
.
_replace
(
usage_id
=
item
.
location
.
replace
(
revision
=
None
)
)
item
.
location
=
item
.
location
.
replace
(
revision
=
None
)
return
item
...
...
common/lib/xmodule/xmodule/modulestore/store_utilities.py
View file @
3f8a2f03
...
...
@@ -110,27 +110,19 @@ def _clone_modules(modulestore, modules, source_location, dest_location):
original_loc
=
Location
(
module
.
location
)
if
original_loc
.
category
!=
'course'
:
new_
location
=
module
.
location
.
_replace
(
module
.
location
=
module
.
location
.
_replace
(
tag
=
dest_location
.
tag
,
org
=
dest_location
.
org
,
course
=
dest_location
.
course
)
module
.
scope_ids
=
module
.
scope_ids
.
_replace
(
def_id
=
new_location
,
usage_id
=
new_location
)
else
:
# on the course module we also have to update the module name
new_
location
=
module
.
location
.
_replace
(
module
.
location
=
module
.
location
.
_replace
(
tag
=
dest_location
.
tag
,
org
=
dest_location
.
org
,
course
=
dest_location
.
course
,
name
=
dest_location
.
name
)
module
.
scope_ids
=
module
.
scope_ids
.
_replace
(
def_id
=
new_location
,
usage_id
=
new_location
)
print
"Cloning module {0} to {1}...."
.
format
(
original_loc
,
module
.
location
)
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
3f8a2f03
...
...
@@ -375,30 +375,22 @@ def remap_namespace(module, target_location_namespace):
# This looks a bit wonky as we need to also change the 'name' of the imported course to be what
# the caller passed in
if
module
.
location
.
category
!=
'course'
:
new_
location
=
module
.
location
.
_replace
(
module
.
location
=
module
.
location
.
_replace
(
tag
=
target_location_namespace
.
tag
,
org
=
target_location_namespace
.
org
,
course
=
target_location_namespace
.
course
)
module
.
scope_ids
=
module
.
scope_ids
.
_replace
(
def_id
=
new_location
,
usage_id
=
new_location
)
else
:
original_location
=
module
.
location
#
# module is a course module
#
new_
location
=
module
.
location
.
_replace
(
module
.
location
=
module
.
location
.
_replace
(
tag
=
target_location_namespace
.
tag
,
org
=
target_location_namespace
.
org
,
course
=
target_location_namespace
.
course
,
name
=
target_location_namespace
.
name
)
module
.
scope_ids
=
module
.
scope_ids
.
_replace
(
def_id
=
new_location
,
usage_id
=
new_location
)
#
# There is more re-namespacing work we have to do when importing course modules
#
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
3f8a2f03
...
...
@@ -146,6 +146,13 @@ class XModule(XModuleFields, HTMLSnippet, XBlock):
else
:
return
BlockUsageLocator
(
self
.
scope_ids
.
usage_id
)
@location.setter
def
location
(
self
,
value
):
self
.
scope_ids
=
self
.
scope_ids
.
_replace
(
def_id
=
value
,
usage_id
=
value
,
)
@property
def
url_name
(
self
):
if
self
.
descriptor
:
...
...
@@ -457,6 +464,13 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock):
else
:
return
BlockUsageLocator
(
self
.
scope_ids
.
usage_id
)
@location.setter
def
location
(
self
,
value
):
self
.
scope_ids
=
self
.
scope_ids
.
_replace
(
def_id
=
value
,
usage_id
=
value
,
)
@property
def
url_name
(
self
):
if
isinstance
(
self
.
location
,
Location
):
...
...
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