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
1cd81a2a
Commit
1cd81a2a
authored
Sep 21, 2012
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work-in-progress: As a problem author, I would like to be able to edit module metadata
parent
2d35e48b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
0 deletions
+29
-0
cms/djangoapps/contentstore/views.py
+6
-0
cms/static/coffee/src/models/module.coffee
+12
-0
cms/templates/widgets/html-edit.html
+1
-0
cms/templates/widgets/metadata-edit.html
+8
-0
cms/templates/widgets/raw-edit.html
+1
-0
common/lib/xmodule/xmodule/editing_module.py
+1
-0
No files found.
cms/djangoapps/contentstore/views.py
View file @
1cd81a2a
...
...
@@ -110,6 +110,7 @@ def edit_item(request):
'category'
:
item
.
category
,
'url_name'
:
item
.
url_name
,
'previews'
:
get_module_previews
(
request
,
item
),
'metadata'
:
item
.
metadata
})
...
...
@@ -279,6 +280,11 @@ def save_item(request):
data
=
json
.
loads
(
request
.
POST
[
'data'
])
modulestore
()
.
update_item
(
item_location
,
data
)
# cdodge: also commit any metadata which might have been passed along in the
# POST from the client
if
request
.
POST
[
'metadata'
]:
modulestore
()
.
update_metadata
(
item_location
,
request
.
POST
[
'metadata'
])
# Export the course back to github
# This uses wildcarding to find the course, which requires handling
# multiple courses returned, but there should only ever be one
...
...
cms/static/coffee/src/models/module.coffee
View file @
1cd81a2a
...
...
@@ -2,14 +2,26 @@ class CMS.Models.Module extends Backbone.Model
url
:
'/save_item'
defaults
:
data
:
''
metadata
:
{}
loadModule
:
(
element
)
->
elt
=
$
(
element
).
find
(
'.xmodule_edit'
).
first
()
@
module
=
XModule
.
loadModule
(
elt
)
# find the metadata edit region which should be setup server side,
# so that we can wire up posting back those changes
@
metadata_elt
=
$
(
element
).
find
(
'.metadata_edit'
)
editUrl
:
->
"/edit_item?
#{
$
.
param
(
id
:
@
get
(
'id'
))
}
"
save
:
(
args
...)
->
@
set
(
data
:
JSON
.
stringify
(
@
module
.
save
()))
if
@
module
# cdodge: package up metadata which is separated into a number of input fields
# there's probably a better way to do this, but at least this lets me continue to move onwards
if
@
metadata_elt
_metadata
=
{}
# walk through the set of elments which have the 'xmetadata_name' attribute and
# build up a object to pass back to the server on the subsequent POST
_metadata
[
el
.
getAttribute
(
"xmetadata_name"
)]
=
el
.
value
for
el
in
$
(
'[xmetadata_name]'
)
@
set
(
metadata
:
_metadata
)
super
(
args
...)
cms/templates/widgets/html-edit.html
View file @
1cd81a2a
<
%
include
file=
"metadata-edit.html"
/>
<section
class=
"html-edit"
>
<textarea
name=
""
class=
"edit-box"
rows=
"8"
cols=
"40"
>
${data}
</textarea>
</section>
cms/templates/widgets/metadata-edit.html
0 → 100644
View file @
1cd81a2a
<section
class=
"metadata_edit"
>
<h3>
Metadata
</h3>
<ul>
% for keyname in metadata.keys():
<li>
${keyname}:
<input
type=
'text'
xmetadata_name=
'${keyname}'
value=
'${metadata[keyname]}'
size=
'60'
/></li>
% endfor
</ul>
</section>
cms/templates/widgets/raw-edit.html
View file @
1cd81a2a
<
%
include
file=
"metadata-edit.html"
/>
<section
class=
"raw-edit"
>
<textarea
name=
""
class=
"edit-box"
rows=
"8"
cols=
"40"
>
${data | h}
</textarea>
</section>
common/lib/xmodule/xmodule/editing_module.py
View file @
1cd81a2a
...
...
@@ -21,6 +21,7 @@ class EditingDescriptor(MakoModuleDescriptor):
return
{
'module'
:
self
,
'data'
:
self
.
definition
.
get
(
'data'
,
''
),
'metadata'
:
self
.
metadata
# TODO (vshnayder): allow children and metadata to be edited.
#'children' : self.definition.get('children, ''),
...
...
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