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
258a467f
Commit
258a467f
authored
Oct 13, 2012
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make delete unit delete both the draft and non-draft versions
parent
2e43d2eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
cms/djangoapps/contentstore/views.py
+16
-16
cms/static/js/base.js
+1
-1
No files found.
cms/djangoapps/contentstore/views.py
View file @
258a467f
...
@@ -210,8 +210,6 @@ def edit_subsection(request, location):
...
@@ -210,8 +210,6 @@ def edit_subsection(request, location):
policy_metadata
=
dict
((
key
,
value
)
for
key
,
value
in
item
.
metadata
.
iteritems
()
policy_metadata
=
dict
((
key
,
value
)
for
key
,
value
in
item
.
metadata
.
iteritems
()
if
key
not
in
[
'display_name'
,
'start'
,
'due'
,
'format'
]
and
key
not
in
item
.
system_metadata_fields
)
if
key
not
in
[
'display_name'
,
'start'
,
'due'
,
'format'
]
and
key
not
in
item
.
system_metadata_fields
)
logging
.
debug
(
policy_metadata
)
return
render_to_response
(
'edit_subsection.html'
,
return
render_to_response
(
'edit_subsection.html'
,
{
'subsection'
:
item
,
{
'subsection'
:
item
,
'context_course'
:
course
,
'context_course'
:
course
,
...
@@ -483,20 +481,13 @@ def _xmodule_recurse(item, action):
...
@@ -483,20 +481,13 @@ def _xmodule_recurse(item, action):
_xmodule_recurse
(
child
,
action
)
_xmodule_recurse
(
child
,
action
)
action
(
item
)
action
(
item
)
def
_delete_item
(
item
,
recurse
=
False
):
if
recurse
:
children
=
item
.
get_children
()
for
child
in
children
:
_delete_item
(
child
,
recurse
)
modulestore
()
.
delete_item
(
item
.
location
);
@login_required
@login_required
@expect_json
@expect_json
def
delete_item
(
request
):
def
delete_item
(
request
):
item_location
=
request
.
POST
[
'id'
]
item_location
=
request
.
POST
[
'id'
]
item_loc
=
Location
(
item_location
)
# check permissions for this user within this course
# check permissions for this user within this course
if
not
has_access
(
request
.
user
,
item_location
):
if
not
has_access
(
request
.
user
,
item_location
):
...
@@ -504,16 +495,28 @@ def delete_item(request):
...
@@ -504,16 +495,28 @@ def delete_item(request):
# optional parameter to delete all children (default False)
# optional parameter to delete all children (default False)
delete_children
=
request
.
POST
.
get
(
'delete_children'
,
False
)
delete_children
=
request
.
POST
.
get
(
'delete_children'
,
False
)
delete_all_versions
=
request
.
POST
.
get
(
'delete_all_versions'
,
False
)
item
=
modulestore
()
.
get_item
(
item_location
)
item
=
modulestore
()
.
get_item
(
item_location
)
store
=
_modulestore
(
item_loc
)
# @TODO: this probably leaves draft items dangling.
# @TODO: this probably leaves draft items dangling. My preferance would be for the semantic to be
# if item.location.revision=None, then delete both draft and published version
# if caller wants to only delete the draft than the caller should put item.location.revision='draft'
if
delete_children
:
if
delete_children
:
_xmodule_recurse
(
item
,
lambda
i
:
_modulestore
(
i
.
location
)
.
delete_item
(
i
.
location
))
_xmodule_recurse
(
item
,
lambda
i
:
store
.
delete_item
(
i
.
location
))
else
:
else
:
_modulestore
(
item
.
location
)
.
delete_item
(
item
.
location
)
store
.
delete_item
(
item
.
location
)
# cdodge: this is a bit of a hack until I can talk with Cale about the
# semantics of delete_item whereby the store is draft aware. Right now calling
# delete_item on a vertical tries to delete the draft version leaving the
# requested delete to never occur
if
item
.
location
.
revision
is
None
and
item
.
location
.
category
==
'vertical'
and
delete_all_versions
:
modulestore
(
'direct'
)
.
delete_item
(
item
.
location
)
return
HttpResponse
()
return
HttpResponse
()
...
@@ -886,9 +889,6 @@ def create_new_course(request):
...
@@ -886,9 +889,6 @@ def create_new_course(request):
if
existing_course
is
not
None
:
if
existing_course
is
not
None
:
return
HttpResponse
(
json
.
dumps
({
'ErrMsg'
:
'There is already a course defined with this name.'
}))
return
HttpResponse
(
json
.
dumps
({
'ErrMsg'
:
'There is already a course defined with this name.'
}))
logging
.
debug
(
dest_location
)
logging
.
debug
(
template
)
new_course
=
modulestore
(
'direct'
)
.
clone_item
(
template
,
dest_location
)
new_course
=
modulestore
(
'direct'
)
.
clone_item
(
template
,
dest_location
)
if
display_name
is
not
None
:
if
display_name
is
not
None
:
...
...
cms/static/js/base.js
View file @
258a467f
...
@@ -244,7 +244,7 @@ function _deleteItem($el) {
...
@@ -244,7 +244,7 @@ function _deleteItem($el) {
var
id
=
$el
.
data
(
'id'
);
var
id
=
$el
.
data
(
'id'
);
$
.
post
(
'/delete_item'
,
$
.
post
(
'/delete_item'
,
{
'id'
:
id
,
'delete_children'
:
true
},
{
'id'
:
id
,
'delete_children'
:
true
,
'delete_all_versions'
:
true
},
function
(
data
)
{
function
(
data
)
{
$el
.
remove
();
$el
.
remove
();
});
});
...
...
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