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
9c6d0d6d
Commit
9c6d0d6d
authored
Oct 29, 2013
by
Christina Roberts
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1523 from edx/christina/import-export
Convert import to new URL pattern.
parents
13d9a8c4
15c12bc3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
39 deletions
+26
-39
cms/djangoapps/contentstore/tests/test_contentstore.py
+1
-6
cms/djangoapps/contentstore/tests/test_import_export.py
+18
-19
cms/djangoapps/contentstore/views/import_export.py
+0
-0
cms/templates/import.html
+2
-6
cms/templates/widgets/header.html
+2
-1
cms/urls.py
+3
-7
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
9c6d0d6d
...
@@ -1592,10 +1592,7 @@ class ContentStoreTest(ModuleStoreTestCase):
...
@@ -1592,10 +1592,7 @@ class ContentStoreTest(ModuleStoreTestCase):
# go to various pages
# go to various pages
# import page
# import page
resp
=
self
.
client
.
get
(
reverse
(
'import_course'
,
resp
=
self
.
client
.
get
(
new_location
.
url_reverse
(
'import/'
,
''
),
HTTP_ACCEPT
=
'text/html'
)
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# export page
# export page
...
@@ -1632,9 +1629,7 @@ class ContentStoreTest(ModuleStoreTestCase):
...
@@ -1632,9 +1629,7 @@ class ContentStoreTest(ModuleStoreTestCase):
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# assets_handler (HTML for full page content)
# assets_handler (HTML for full page content)
new_location
=
loc_mapper
()
.
translate_location
(
loc
.
course_id
,
loc
,
False
,
True
)
url
=
new_location
.
url_reverse
(
'assets/'
,
''
)
url
=
new_location
.
url_reverse
(
'assets/'
,
''
)
resp
=
self
.
client
.
get
(
url
,
HTTP_ACCEPT
=
'text/html'
)
resp
=
self
.
client
.
get
(
url
,
HTTP_ACCEPT
=
'text/html'
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
...
...
cms/djangoapps/contentstore/tests/test_import_export.py
View file @
9c6d0d6d
...
@@ -13,9 +13,9 @@ from uuid import uuid4
...
@@ -13,9 +13,9 @@ from uuid import uuid4
from
pymongo
import
MongoClient
from
pymongo
import
MongoClient
from
.utils
import
CourseTestCase
from
.utils
import
CourseTestCase
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
django.conf
import
settings
from
xmodule.modulestore.django
import
loc_mapper
from
xmodule.contentstore.django
import
_CONTENTSTORE
from
xmodule.contentstore.django
import
_CONTENTSTORE
...
@@ -32,11 +32,10 @@ class ImportTestCase(CourseTestCase):
...
@@ -32,11 +32,10 @@ class ImportTestCase(CourseTestCase):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
ImportTestCase
,
self
)
.
setUp
()
super
(
ImportTestCase
,
self
)
.
setUp
()
self
.
url
=
reverse
(
"import_course"
,
kwargs
=
{
self
.
new_location
=
loc_mapper
()
.
translate_location
(
'org'
:
self
.
course
.
location
.
org
,
self
.
course
.
location
.
course_id
,
self
.
course
.
location
,
False
,
True
'course'
:
self
.
course
.
location
.
course
,
)
'name'
:
self
.
course
.
location
.
name
,
self
.
url
=
self
.
new_location
.
url_reverse
(
'import/'
,
''
)
})
self
.
content_dir
=
path
(
tempfile
.
mkdtemp
())
self
.
content_dir
=
path
(
tempfile
.
mkdtemp
())
def
touch
(
name
):
def
touch
(
name
):
...
@@ -89,13 +88,13 @@ class ImportTestCase(CourseTestCase):
...
@@ -89,13 +88,13 @@ class ImportTestCase(CourseTestCase):
self
.
assertEquals
(
resp
.
status_code
,
415
)
self
.
assertEquals
(
resp
.
status_code
,
415
)
# Check that `import_status` returns the appropriate stage (i.e., the
# Check that `import_status` returns the appropriate stage (i.e., the
# stage at which import failed).
# stage at which import failed).
status_url
=
reverse
(
"import_status"
,
kwargs
=
{
resp_status
=
self
.
client
.
get
(
'org'
:
self
.
course
.
location
.
org
,
self
.
new_location
.
url_reverse
(
'course'
:
self
.
course
.
location
.
course
,
'import_status'
,
'name'
:
os
.
path
.
split
(
self
.
bad_tar
)[
1
],
os
.
path
.
split
(
self
.
bad_tar
)[
1
]
}
)
)
resp_status
=
self
.
client
.
get
(
status_url
)
)
log
.
debug
(
str
(
self
.
client
.
session
[
"import_status"
]))
self
.
assertEquals
(
json
.
loads
(
resp_status
.
content
)[
"ImportStatus"
],
2
)
self
.
assertEquals
(
json
.
loads
(
resp_status
.
content
)[
"ImportStatus"
],
2
)
...
@@ -200,11 +199,11 @@ class ImportTestCase(CourseTestCase):
...
@@ -200,11 +199,11 @@ class ImportTestCase(CourseTestCase):
# Check that `import_status` returns the appropriate stage (i.e.,
# Check that `import_status` returns the appropriate stage (i.e.,
# either 3, indicating all previous steps are completed, or 0,
# either 3, indicating all previous steps are completed, or 0,
# indicating no upload in progress)
# indicating no upload in progress)
status_url
=
reverse
(
"import_status"
,
kwargs
=
{
resp_status
=
self
.
client
.
get
(
'org'
:
self
.
course
.
location
.
org
,
self
.
new_location
.
url_reverse
(
'course'
:
self
.
course
.
location
.
course
,
'import_status'
,
'name'
:
os
.
path
.
split
(
self
.
good_tar
)[
1
],
os
.
path
.
split
(
self
.
good_tar
)[
1
]
}
)
)
resp_status
=
self
.
client
.
get
(
status_url
)
)
import_status
=
json
.
loads
(
resp_status
.
content
)[
"ImportStatus"
]
import_status
=
json
.
loads
(
resp_status
.
content
)[
"ImportStatus"
]
self
.
assertIn
(
import_status
,
(
0
,
3
))
self
.
assertIn
(
import_status
,
(
0
,
3
))
cms/djangoapps/contentstore/views/import_export.py
View file @
9c6d0d6d
This diff is collapsed.
Click to expand it.
cms/templates/import.html
View file @
9c6d0d6d
<
%
inherit
file=
"base.html"
/>
<
%
inherit
file=
"base.html"
/>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<
%!
<
%!
from
django
.
core
.
urlresolvers
import
reverse
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
%
>
<
%
block
name=
"title"
>
${_("Course Import")}
</
%
block>
<
%
block
name=
"title"
>
${_("Course Import")}
</
%
block>
...
@@ -28,10 +27,7 @@
...
@@ -28,10 +27,7 @@
<p>
${_("During the initial stages of the import process, please do not navigate away from this page.")}
</p>
<p>
${_("During the initial stages of the import process, please do not navigate away from this page.")}
</p>
</div>
</div>
<form
id=
"fileupload"
method=
"post"
enctype=
"multipart/form-data"
<form
id=
"fileupload"
method=
"post"
enctype=
"multipart/form-data"
class=
"import-form"
>
class=
"import-form"
url=
"${reverse('import_course', kwargs=dict(org=context_course.location.org, course=context_course.location.course, name=context_course.location.name))}"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
/>
## Translators: ".tar.gz" is a file extension, and files with that extension are called "gzipped tar files": these terms should not be translated
## Translators: ".tar.gz" is a file extension, and files with that extension are called "gzipped tar files": these terms should not be translated
<h2
class=
"title"
>
${_("Select a File (.tar.gz format) to Replace Your Course Content")}
</h2>
<h2
class=
"title"
>
${_("Select a File (.tar.gz format) to Replace Your Course Content")}
</h2>
...
@@ -158,7 +154,7 @@ var chooseBtn = $('.choose-file-button');
...
@@ -158,7 +154,7 @@ var chooseBtn = $('.choose-file-button');
var
allStats
=
$
(
'#status-infos'
);
var
allStats
=
$
(
'#status-infos'
);
var
feedbackUrl
=
"${
reverse('import_status', kwargs=dict(org=context_course.location.org, course=context_course.location.course, name='fillerName'))}"
var
feedbackUrl
=
"${
import_status_url}"
;
var
defaults
=
[
var
defaults
=
[
'${_("There was an error during the upload process.")}
\
n'
,
'${_("There was an error during the upload process.")}
\
n'
,
...
...
cms/templates/widgets/header.html
View file @
9c6d0d6d
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
checklists_url =
location.url_reverse('checklists/',
'')
checklists_url =
location.url_reverse('checklists/',
'')
course_team_url =
location.url_reverse('course_team/',
'')
course_team_url =
location.url_reverse('course_team/',
'')
assets_url =
location.url_reverse('assets/',
'')
assets_url =
location.url_reverse('assets/',
'')
import_url =
location.url_reverse('import/',
'')
%
>
%
>
<h2
class=
"info-course"
>
<h2
class=
"info-course"
>
<span
class=
"sr"
>
${_("Current Course:")}
</span>
<span
class=
"sr"
>
${_("Current Course:")}
</span>
...
@@ -91,7 +92,7 @@
...
@@ -91,7 +92,7 @@
<a
href=
"${checklists_url}"
>
${_("Checklists")}
</a>
<a
href=
"${checklists_url}"
>
${_("Checklists")}
</a>
</li>
</li>
<li
class=
"nav-item nav-course-tools-import"
>
<li
class=
"nav-item nav-course-tools-import"
>
<a
href=
"${
reverse('import_course', kwargs=dict(org=ctx_loc.org, course=ctx_loc.course, name=ctx_loc.name))
}"
>
${_("Import")}
</a>
<a
href=
"${
import_url
}"
>
${_("Import")}
</a>
</li>
</li>
<li
class=
"nav-item nav-course-tools-export"
>
<li
class=
"nav-item nav-course-tools-export"
>
<a
href=
"${reverse('export_course', kwargs=dict(org=ctx_loc.org, course=ctx_loc.course, name=ctx_loc.name))}"
>
${_("Export")}
</a>
<a
href=
"${reverse('export_course', kwargs=dict(org=ctx_loc.org, course=ctx_loc.course, name=ctx_loc.name))}"
>
${_("Export")}
</a>
...
...
cms/urls.py
View file @
9c6d0d6d
import
re
from
django.conf
import
settings
from
django.conf
import
settings
from
django.conf.urls
import
patterns
,
include
,
url
from
django.conf.urls
import
patterns
,
include
,
url
...
@@ -34,11 +33,6 @@ urlpatterns = patterns('', # nopep8
...
@@ -34,11 +33,6 @@ urlpatterns = patterns('', # nopep8
url
(
r'^create_new_course'
,
'contentstore.views.create_new_course'
,
name
=
'create_new_course'
),
url
(
r'^create_new_course'
,
'contentstore.views.create_new_course'
,
name
=
'create_new_course'
),
url
(
r'^reorder_static_tabs'
,
'contentstore.views.reorder_static_tabs'
,
name
=
'reorder_static_tabs'
),
url
(
r'^reorder_static_tabs'
,
'contentstore.views.reorder_static_tabs'
,
name
=
'reorder_static_tabs'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/import/(?P<name>[^/]+)$'
,
'contentstore.views.import_course'
,
name
=
'import_course'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/import_status/(?P<name>[^/]+)$'
,
'contentstore.views.import_status'
,
name
=
'import_status'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/export/(?P<name>[^/]+)$'
,
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/export/(?P<name>[^/]+)$'
,
'contentstore.views.export_course'
,
name
=
'export_course'
),
'contentstore.views.export_course'
,
name
=
'export_course'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/generate_export/(?P<name>[^/]+)$'
,
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/generate_export/(?P<name>[^/]+)$'
,
...
@@ -129,7 +123,9 @@ urlpatterns += patterns(
...
@@ -129,7 +123,9 @@ urlpatterns += patterns(
url
(
r'(?ix)^checklists/{}(/)?(?P<checklist_index>\d+)?$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'checklists_handler'
),
url
(
r'(?ix)^checklists/{}(/)?(?P<checklist_index>\d+)?$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'checklists_handler'
),
url
(
r'(?ix)^course_team/{}(/)?(?P<email>.+)?$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'course_team_handler'
),
url
(
r'(?ix)^course_team/{}(/)?(?P<email>.+)?$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'course_team_handler'
),
url
(
r'(?ix)^orphan/{}$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'orphan'
),
url
(
r'(?ix)^orphan/{}$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'orphan'
),
url
(
r'(?ix)^assets/{}(/)?(?P<asset_id>.+)?$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'assets_handler'
)
url
(
r'(?ix)^assets/{}(/)?(?P<asset_id>.+)?$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'assets_handler'
),
url
(
r'(?ix)^import/{}$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'import_handler'
),
url
(
r'(?ix)^import_status/{}/(?P<filename>.+)$'
.
format
(
parsers
.
URL_RE_SOURCE
),
'import_status_handler'
),
)
)
js_info_dict
=
{
js_info_dict
=
{
...
...
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