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
27a28d8a
Commit
27a28d8a
authored
Jul 03, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract import from xml into a separate function
parent
ef134df8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
cms/djangoapps/contentstore/__init__.py
+19
-0
cms/djangoapps/contentstore/management/commands/import.py
+2
-11
No files found.
cms/djangoapps/contentstore/__init__.py
View file @
27a28d8a
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.xml
import
XMLModuleStore
def
import_from_xml
(
org
,
course
,
data_dir
):
"""
Import the specified xml data_dir into the django defined modulestore,
using org and course as the location org and course.
"""
module_store
=
XMLModuleStore
(
org
,
course
,
data_dir
,
'xmodule.raw_module.RawDescriptor'
,
eager
=
True
)
for
module
in
module_store
.
modules
.
itervalues
():
modulestore
()
.
create_item
(
module
.
location
)
if
'data'
in
module
.
definition
:
modulestore
()
.
update_item
(
module
.
location
,
module
.
definition
[
'data'
])
if
'children'
in
module
.
definition
:
modulestore
()
.
update_children
(
module
.
location
,
module
.
definition
[
'children'
])
modulestore
()
.
update_metadata
(
module
.
location
,
dict
(
module
.
metadata
))
return
module_store
.
course
cms/djangoapps/contentstore/management/commands/import.py
View file @
27a28d8a
...
...
@@ -3,8 +3,7 @@
###
from
django.core.management.base
import
BaseCommand
,
CommandError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.xml
import
XMLModuleStore
from
contentstore
import
import_from_xml
unnamed_modules
=
0
...
...
@@ -18,12 +17,4 @@ class Command(BaseCommand):
raise
CommandError
(
"import requires 3 arguments: <org> <course> <data directory>"
)
org
,
course
,
data_dir
=
args
module_store
=
XMLModuleStore
(
org
,
course
,
data_dir
,
'xmodule.raw_module.RawDescriptor'
,
eager
=
True
)
for
module
in
module_store
.
modules
.
itervalues
():
modulestore
()
.
create_item
(
module
.
location
)
if
'data'
in
module
.
definition
:
modulestore
()
.
update_item
(
module
.
location
,
module
.
definition
[
'data'
])
if
'children'
in
module
.
definition
:
modulestore
()
.
update_children
(
module
.
location
,
module
.
definition
[
'children'
])
modulestore
()
.
update_metadata
(
module
.
location
,
dict
(
module
.
metadata
))
import_from_xml
(
org
,
course
,
data_dir
)
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