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
cb2243a4
Commit
cb2243a4
authored
Mar 11, 2014
by
Usman Khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not remap the wiki_slug if reimporting into the same course.
LMS-2136
parent
be239bdb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
15 deletions
+35
-15
cms/djangoapps/contentstore/tests/test_contentstore.py
+22
-3
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+13
-12
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
cb2243a4
...
...
@@ -1763,6 +1763,26 @@ class ContentStoreTest(ModuleStoreTestCase):
def
test_import_into_new_course_id_wiki_slug_renamespacing
(
self
):
module_store
=
modulestore
(
'direct'
)
# If reimporting into the same course do not change the wiki_slug.
target_location
=
Location
(
'i4x'
,
'edX'
,
'toy'
,
'course'
,
'2012_Fall'
)
course_data
=
{
'org'
:
target_location
.
org
,
'number'
:
target_location
.
course
,
'display_name'
:
'Robot Super Course'
,
'run'
:
target_location
.
name
}
_create_course
(
self
,
course_data
)
course_module
=
module_store
.
get_instance
(
target_location
.
course_id
,
target_location
)
course_module
.
wiki_slug
=
'toy'
course_module
.
save
()
# Import a course with wiki_slug == location.course
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'toy'
],
target_location_namespace
=
target_location
)
course_module
=
module_store
.
get_instance
(
target_location
.
course_id
,
target_location
)
self
.
assertEquals
(
course_module
.
wiki_slug
,
'toy'
)
# But change the wiki_slug if it is a different course.
target_location
=
Location
(
'i4x'
,
'MITx'
,
'999'
,
'course'
,
'2013_Spring'
)
course_data
=
{
'org'
:
target_location
.
org
,
...
...
@@ -1770,7 +1790,6 @@ class ContentStoreTest(ModuleStoreTestCase):
'display_name'
:
'Robot Super Course'
,
'run'
:
target_location
.
name
}
target_course_id
=
'{0}/{1}/{2}'
.
format
(
target_location
.
org
,
target_location
.
course
,
target_location
.
name
)
_create_course
(
self
,
course_data
)
# Import a course with wiki_slug == location.course
...
...
@@ -1778,9 +1797,9 @@ class ContentStoreTest(ModuleStoreTestCase):
course_module
=
module_store
.
get_instance
(
target_location
.
course_id
,
target_location
)
self
.
assertEquals
(
course_module
.
wiki_slug
,
'MITx.999.2013_Spring'
)
# Now try importing a course with wiki_slug == '{0}
{1}
{2}'.format(location.org, location.course, location.name)
# Now try importing a course with wiki_slug == '{0}
.{1}.
{2}'.format(location.org, location.course, location.name)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'two_toys'
],
target_location_namespace
=
target_location
)
course_module
=
module_store
.
get_instance
(
target_course_id
,
target_location
)
course_module
=
module_store
.
get_instance
(
target_
location
.
course_id
,
target_location
)
self
.
assertEquals
(
course_module
.
wiki_slug
,
'MITx.999.2013_Spring'
)
def
test_import_metadata_with_attempts_empty_string
(
self
):
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
cb2243a4
...
...
@@ -515,19 +515,20 @@ def remap_namespace(module, target_location_namespace):
)
# Original wiki_slugs had value location.course. To make them unique this was changed to 'org.course.name'.
# If the wiki_slug is equal to either of these default values then remap that so that the wiki does not point
# to the old wiki.
original_unique_wiki_slug
=
'{0}.{1}.{2}'
.
format
(
original_location
.
org
,
original_location
.
course
,
original_location
.
name
)
if
module
.
wiki_slug
==
original_unique_wiki_slug
or
module
.
wiki_slug
==
original_location
.
course
:
module
.
wiki_slug
=
'{0}.{1}.{2}'
.
format
(
target_location_namespace
.
org
,
target_location_namespace
.
course
,
target_location_namespace
.
name
,
# If we are importing into a course with a different course_id and wiki_slug is equal to either of these default
# values then remap it so that the wiki does not point to the old wiki.
if
original_location
.
course_id
!=
target_location_namespace
.
course_id
:
original_unique_wiki_slug
=
'{0}.{1}.{2}'
.
format
(
original_location
.
org
,
original_location
.
course
,
original_location
.
name
)
if
module
.
wiki_slug
==
original_unique_wiki_slug
or
module
.
wiki_slug
==
original_location
.
course
:
module
.
wiki_slug
=
'{0}.{1}.{2}'
.
format
(
target_location_namespace
.
org
,
target_location_namespace
.
course
,
target_location_namespace
.
name
,
)
module
.
save
()
...
...
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