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
c6760463
Commit
c6760463
authored
Jan 30, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding exporting of tabs and custom_tags. Also added unit tests
parent
8720d1ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
cms/djangoapps/contentstore/tests/tests.py
+24
-0
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
+23
-0
No files found.
cms/djangoapps/contentstore/tests/tests.py
View file @
c6760463
...
...
@@ -8,6 +8,8 @@ from django.core.urlresolvers import reverse
from
path
import
path
from
tempfile
import
mkdtemp
import
json
from
fs.osfs
import
OSFS
from
student.models
import
Registration
from
django.contrib.auth.models
import
User
...
...
@@ -430,6 +432,28 @@ class ContentStoreTest(TestCase):
# export out to a tempdir
export_to_xml
(
ms
,
cs
,
location
,
root_dir
,
'test_export'
)
# check for static tabs
fs
=
OSFS
(
root_dir
/
'test_export'
)
self
.
assertTrue
(
fs
.
exists
(
'tabs'
))
static_tabs_query_loc
=
Location
(
'i4x'
,
location
.
org
,
location
.
course
,
'static_tab'
,
None
)
static_tabs
=
ms
.
get_items
(
static_tabs_query_loc
)
for
static_tab
in
static_tabs
:
fs
=
OSFS
(
root_dir
/
'test_export/tabs'
)
self
.
assertTrue
(
fs
.
exists
(
static_tab
.
location
.
name
+
'.html'
))
# check for custom_tags
fs
=
OSFS
(
root_dir
/
'test_export'
)
self
.
assertTrue
(
fs
.
exists
(
'custom_tags'
))
custom_tags_query_loc
=
Location
(
'i4x'
,
location
.
org
,
location
.
course
,
'custom_tag_template'
,
None
)
custom_tags
=
ms
.
get_items
(
custom_tags_query_loc
)
for
custom_tag
in
custom_tags
:
fs
=
OSFS
(
root_dir
/
'test_export/custom_tags'
)
self
.
assertTrue
(
fs
.
exists
(
custom_tag
.
location
.
name
))
# remove old course
delete_course
(
ms
,
cs
,
location
)
...
...
common/lib/xmodule/xmodule/modulestore/xml_exporter.py
View file @
c6760463
...
...
@@ -17,4 +17,26 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
# export the static assets
contentstore
.
export_all_for_course
(
course_location
,
root_dir
+
'/'
+
course_dir
+
'/static/'
)
# export the static tabs
static_tabs_query_loc
=
Location
(
'i4x'
,
course_location
.
org
,
course_location
.
course
,
'static_tab'
,
None
)
static_tabs
=
modulestore
.
get_items
(
static_tabs_query_loc
)
if
len
(
static_tabs
)
>
0
:
tab_dir
=
export_fs
.
makeopendir
(
'tabs'
)
for
tab
in
static_tabs
:
with
tab_dir
.
open
(
tab
.
location
.
name
+
'.html'
,
'w'
)
as
tab_file
:
tab_file
.
write
(
tab
.
definition
[
'data'
]
.
encode
(
'utf8'
))
# export custom tags
custom_tags_query_loc
=
Location
(
'i4x'
,
course_location
.
org
,
course_location
.
course
,
'custom_tag_template'
,
None
)
custom_tags
=
modulestore
.
get_items
(
custom_tags_query_loc
)
if
len
(
custom_tags
)
>
0
:
tab_dir
=
export_fs
.
makeopendir
(
'custom_tags'
)
for
tag
in
custom_tags
:
with
tab_dir
.
open
(
tag
.
location
.
name
,
'w'
)
as
tag_file
:
tag_file
.
write
(
tag
.
definition
[
'data'
]
.
encode
(
'utf8'
))
\ No newline at end of file
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