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
3107bb9c
Commit
3107bb9c
authored
Sep 21, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make separate json and xml editing interfaces
parent
33f9eae3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
16 deletions
+41
-16
common/lib/xmodule/xmodule/editing_module.py
+22
-6
common/lib/xmodule/xmodule/error_module.py
+2
-2
common/lib/xmodule/xmodule/js/src/raw/edit.coffee
+0
-5
common/lib/xmodule/xmodule/js/src/raw/edit/json.coffee
+7
-0
common/lib/xmodule/xmodule/js/src/raw/edit/xml.coffee
+7
-0
common/lib/xmodule/xmodule/raw_module.py
+3
-3
No files found.
common/lib/xmodule/xmodule/editing_module.py
View file @
3107bb9c
...
...
@@ -5,6 +5,7 @@ import logging
log
=
logging
.
getLogger
(
__name__
)
class
EditingDescriptor
(
MakoModuleDescriptor
):
"""
Module that provides a raw editing view of its data and children. It does not
...
...
@@ -14,16 +15,31 @@ class EditingDescriptor(MakoModuleDescriptor):
"""
mako_template
=
"widgets/raw-edit.html"
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/src/raw/edit.coffee'
)]}
js_module_name
=
"RawDescriptor"
# cdodge: a little refactoring here, since we're basically doing the same thing
# here as with our parent class, let's call into it to get the basic fields
# set and then add our additional fields. Trying to keep it DRY.
def
get_context
(
self
):
_context
=
MakoModuleDescriptor
.
get_context
(
self
)
# Add our specific template information (the raw data body)
_context
.
update
({
'data'
:
self
.
definition
.
get
(
'data'
,
''
)
})
_context
.
update
({
'data'
:
self
.
definition
.
get
(
'data'
,
''
)
})
return
_context
class
XMLEditingDescriptor
(
EditingDescriptor
):
"""
Module that provides a raw editing view of its data as XML. It does not perform
any validation of its definition
"""
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/src/raw/edit/xml.coffee'
)]}
js_module_name
=
"XMLEditingDescriptor"
class
JSONEditingDescriptor
(
EditingDescriptor
):
"""
Module that provides a raw editing view of its data as XML. It does not perform
any validation of its definition
"""
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/src/raw/edit/json.coffee'
)]}
js_module_name
=
"JSONEditingDescriptor"
common/lib/xmodule/xmodule/error_module.py
View file @
3107bb9c
...
...
@@ -5,7 +5,7 @@ import sys
from
lxml
import
etree
from
xmodule.x_module
import
XModule
from
xmodule.editing_module
import
EditingDescriptor
from
xmodule.editing_module
import
JSON
EditingDescriptor
from
xmodule.errortracker
import
exc_info_to_str
...
...
@@ -45,7 +45,7 @@ class NonStaffErrorModule(XModule):
})
class
ErrorDescriptor
(
EditingDescriptor
):
class
ErrorDescriptor
(
JSON
EditingDescriptor
):
"""
Module that provides a raw editing view of broken xml.
"""
...
...
common/lib/xmodule/xmodule/js/src/raw/edit.coffee
deleted
100644 → 0
View file @
33f9eae3
class
@
RawDescriptor
constructor
:
(
@
element
)
->
@
edit_box
=
$
(
".edit-box"
,
@
element
)
save
:
->
@
edit_box
.
val
()
common/lib/xmodule/xmodule/js/src/raw/edit/json.coffee
0 → 100644
View file @
3107bb9c
class
@
JSONEditingDescriptor
constructor
:
(
@
element
)
->
@
edit_box
=
CodeMirror
.
fromTextArea
(
$
(
".edit-box"
,
@
element
)[
0
],
{
mode
:
{
name
:
"javascript"
,
json
:
true
}
})
save
:
->
JSON
.
parse
@
edit_box
.
getValue
()
common/lib/xmodule/xmodule/js/src/raw/edit/xml.coffee
0 → 100644
View file @
3107bb9c
class
@
XMLEditingDescriptor
constructor
:
(
@
element
)
->
@
edit_box
=
CodeMirror
.
fromTextArea
(
$
(
".edit-box"
,
@
element
)[
0
],
{
mode
:
"xml"
})
save
:
->
@
edit_box
.
getValue
()
common/lib/xmodule/xmodule/raw_module.py
View file @
3107bb9c
from
lxml
import
etree
from
xmodule.editing_module
import
EditingDescriptor
from
xmodule.editing_module
import
XML
EditingDescriptor
from
xmodule.xml_module
import
XmlDescriptor
import
logging
import
sys
log
=
logging
.
getLogger
(
__name__
)
class
RawDescriptor
(
XmlDescriptor
,
EditingDescriptor
):
class
RawDescriptor
(
XmlDescriptor
,
XML
EditingDescriptor
):
"""
Module that provides a raw editing view of its data and children. It
requires that the definition xml is valid.
"""
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
return
{
'data'
:
etree
.
tostring
(
xml_object
)}
return
{
'data'
:
etree
.
tostring
(
xml_object
,
pretty_print
=
True
)}
def
definition_to_xml
(
self
,
resource_fs
):
try
:
...
...
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