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
baaafb9d
Commit
baaafb9d
authored
Oct 03, 2012
by
chrisndodge
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #815 from MITx/feature/cale/cas-component-delete
Feature/cale/cas component delete
parents
153d5d69
d80c9317
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
11 deletions
+47
-11
cms/djangoapps/contentstore/views.py
+9
-6
cms/static/coffee/src/views/module_edit.coffee
+2
-2
cms/static/coffee/src/views/unit.coffee
+12
-1
cms/templates/component.html
+1
-1
cms/urls.py
+1
-0
common/lib/xmodule/xmodule/modulestore/__init__.py
+8
-0
common/lib/xmodule/xmodule/modulestore/mongo.py
+8
-0
common/lib/xmodule/xmodule/x_module.py
+6
-1
No files found.
cms/djangoapps/contentstore/views.py
View file @
baaafb9d
...
...
@@ -385,6 +385,14 @@ def get_module_previews(request, descriptor):
@login_required
@expect_json
def
delete_item
(
request
):
item_location
=
request
.
POST
[
'id'
]
modulestore
()
.
delete_item
(
item_location
)
return
HttpResponse
()
@login_required
@expect_json
def
save_item
(
request
):
item_location
=
request
.
POST
[
'id'
]
...
...
@@ -413,12 +421,7 @@ def save_item(request):
existing_item
.
metadata
.
update
(
posted_metadata
)
modulestore
()
.
update_metadata
(
item_location
,
existing_item
.
metadata
)
descriptor
=
modulestore
()
.
get_item
(
item_location
)
preview_html
=
get_module_previews
(
request
,
descriptor
)[
0
]
return
HttpResponse
(
json
.
dumps
({
'preview'
:
preview_html
}))
return
HttpResponse
()
@login_required
...
...
cms/static/coffee/src/views/module_edit.coffee
View file @
baaafb9d
...
...
@@ -6,10 +6,10 @@ class CMS.Views.ModuleEdit extends Backbone.View
"click .component-editor .cancel-button"
:
'clickCancelButton'
"click .component-editor .save-button"
:
'clickSaveButton'
"click .component-actions .edit-button"
:
'clickEditButton'
"click .component-actions .delete-button"
:
'onDelete'
initialize
:
->
@
module
=
@
options
.
modul
e
@
onDelete
=
@
options
.
onDelet
e
@
render
()
$component_editor
:
=>
@
$el
.
find
(
'.component-editor'
)
...
...
cms/static/coffee/src/views/unit.coffee
View file @
baaafb9d
...
...
@@ -18,9 +18,10 @@ class CMS.Views.UnitEdit extends Backbone.View
update
:
(
event
,
ui
)
=>
@
saveOrder
()
)
@
$
(
'.component'
).
each
((
idx
,
element
)
-
>
@
$
(
'.component'
).
each
((
idx
,
element
)
=
>
new
CMS
.
Views
.
ModuleEdit
(
el
:
element
,
onDelete
:
@
deleteComponent
,
model
:
new
CMS
.
Models
.
Module
(
id
:
$
(
element
).
data
(
'id'
),
)
...
...
@@ -70,3 +71,13 @@ class CMS.Views.UnitEdit extends Backbone.View
@
model
.
save
(
children
:
@
components
()
)
deleteComponent
:
(
event
)
=>
$component
=
$
(
event
.
currentTarget
).
parents
(
'.component'
)
$
.
post
(
'/delete_item'
,
{
id
:
$component
.
data
(
'id'
)
},
=>
$component
.
remove
()
@
saveOrder
()
)
cms/templates/component.html
View file @
baaafb9d
${preview}
<div
class=
"component-actions"
>
<a
href=
"#"
class=
"edit-button"
><span
class=
"edit-icon white"
></span>
Edit
</a>
<a
href=
"#"
class=
"delete-button
wip
"
><span
class=
"delete-icon white"
></span>
Delete
</a>
<a
href=
"#"
class=
"delete-button"
><span
class=
"delete-icon white"
></span>
Delete
</a>
</div>
<a
href=
"#"
class=
"drag-handle"
></a>
<div
class=
"component-editor"
>
...
...
cms/urls.py
View file @
baaafb9d
...
...
@@ -14,6 +14,7 @@ urlpatterns = ('',
url
(
r'^delete/(?P<location>.*?)$'
,
'contentstore.views.delete_unit'
,
name
=
'delete_unit'
),
url
(
r'^preview_component/(?P<location>.*?)$'
,
'contentstore.views.preview_component'
,
name
=
'preview_component'
),
url
(
r'^save_item$'
,
'contentstore.views.save_item'
,
name
=
'save_item'
),
url
(
r'^delete_item$'
,
'contentstore.views.delete_item'
,
name
=
'delete_item'
),
url
(
r'^clone_item$'
,
'contentstore.views.clone_item'
,
name
=
'clone_item'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<name>[^/]+)$'
,
'contentstore.views.course_index'
,
name
=
'course_index'
),
...
...
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
baaafb9d
...
...
@@ -332,6 +332,14 @@ class ModuleStore(object):
"""
raise
NotImplementedError
def
delete_item
(
self
,
location
):
"""
Delete an item from this modulestore
location: Something that can be passed to Location
"""
raise
NotImplementedError
def
get_courses
(
self
):
'''
Returns a list containing the top level XModuleDescriptors of the courses
...
...
common/lib/xmodule/xmodule/modulestore/mongo.py
View file @
baaafb9d
...
...
@@ -309,6 +309,14 @@ class MongoModuleStore(ModuleStoreBase):
self
.
_update_single_item
(
location
,
{
'metadata'
:
metadata
})
def
delete_item
(
self
,
location
):
"""
Delete an item from this modulestore
location: Something that can be passed to Location
"""
self
.
collection
.
remove
({
'_id'
:
Location
(
location
)
.
dict
()})
def
get_parent_locations
(
self
,
location
):
'''Find all locations that are the parents of this location. Needed
for path_to_location().
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
baaafb9d
...
...
@@ -13,6 +13,7 @@ from xmodule.modulestore import Location
from
xmodule.timeparse
import
parse_time
from
xmodule.contentstore.content
import
StaticContent
,
XASSET_SRCREF_PREFIX
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
log
=
logging
.
getLogger
(
'mitx.'
+
__name__
)
...
...
@@ -531,7 +532,11 @@ class XModuleDescriptor(Plugin, HTMLSnippet, ResourceTemplates):
if
self
.
_child_instances
is
None
:
self
.
_child_instances
=
[]
for
child_loc
in
self
.
definition
.
get
(
'children'
,
[]):
child
=
self
.
system
.
load_item
(
child_loc
)
try
:
child
=
self
.
system
.
load_item
(
child_loc
)
except
ItemNotFoundError
:
log
.
exception
(
'Unable to load item {loc}, skipping'
.
format
(
loc
=
child_loc
))
continue
# TODO (vshnayder): this should go away once we have
# proper inheritance support in mongo. The xml
# datastore does all inheritance on course load.
...
...
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