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
dc2dbb34
Commit
dc2dbb34
authored
Mar 12, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do metadata name translation in json import as well as xml import
parent
8ace7eeb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
12 deletions
+17
-12
common/lib/xmodule/xmodule/x_module.py
+17
-0
common/lib/xmodule/xmodule/xml_module.py
+0
-12
No files found.
common/lib/xmodule/xmodule/x_module.py
View file @
dc2dbb34
...
...
@@ -358,6 +358,14 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock):
default
=
None
,
)
# VS[compat]. Backwards compatibility code that can go away after
# importing 2012 courses.
# A set of metadata key conversions that we want to make
metadata_translations
=
{
'slug'
:
'url_name'
,
'name'
:
'display_name'
,
}
# ============================= STRUCTURAL MANIPULATION ===================
def
__init__
(
self
,
system
,
...
...
@@ -493,6 +501,10 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock):
system: A DescriptorSystem for interacting with external resources
"""
model_data
=
{}
for
key
,
value
in
json_data
.
get
(
'metadata'
,
{})
.
items
():
model_data
[
cls
.
_translate
(
key
)]
=
value
model_data
.
update
(
json_data
.
get
(
'metadata'
,
{}))
definition
=
json_data
.
get
(
'definition'
,
{})
...
...
@@ -507,6 +519,11 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock):
return
cls
(
system
=
system
,
location
=
json_data
[
'location'
],
model_data
=
model_data
)
@classmethod
def
_translate
(
cls
,
key
):
'VS[compat]'
return
cls
.
metadata_translations
.
get
(
key
,
key
)
# ================================= XML PARSING ============================
@staticmethod
def
load_from_xml
(
xml_data
,
...
...
common/lib/xmodule/xmodule/xml_module.py
View file @
dc2dbb34
...
...
@@ -137,18 +137,6 @@ class XmlDescriptor(XModuleDescriptor):
'allow_anonymous_to_peers'
:
bool_map
}
# VS[compat]. Backwards compatibility code that can go away after
# importing 2012 courses.
# A set of metadata key conversions that we want to make
metadata_translations
=
{
'slug'
:
'url_name'
,
'name'
:
'display_name'
,
}
@classmethod
def
_translate
(
cls
,
key
):
'VS[compat]'
return
cls
.
metadata_translations
.
get
(
key
,
key
)
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
...
...
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