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
5390a19f
Commit
5390a19f
authored
Oct 03, 2012
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete unit in overview and subsection_edit pages
parent
35d1966d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
8 deletions
+43
-8
cms/djangoapps/contentstore/views.py
+22
-5
cms/static/js/base.js
+16
-0
cms/templates/widgets/units.html
+5
-2
cms/urls.py
+0
-1
No files found.
cms/djangoapps/contentstore/views.py
View file @
5390a19f
...
...
@@ -209,10 +209,6 @@ def preview_component(request, location):
})
@login_required
def
delete_unit
(
request
,
location
):
pass
def
user_author_string
(
user
):
'''Get an author string for commits by this user. Format:
...
...
@@ -382,12 +378,33 @@ def get_module_previews(request, descriptor):
preview_html
.
append
(
module
.
get_html
())
return
preview_html
def
_delete_item
(
item
,
recurse
=
False
):
if
recurse
:
children
=
item
.
get_children
()
for
child
in
children
:
_delete_item
(
child
)
modulestore
()
.
delete_item
(
item
.
location
);
@login_required
@expect_json
def
delete_item
(
request
):
item_location
=
request
.
POST
[
'id'
]
modulestore
()
.
delete_item
(
item_location
)
# check permissions for this user within this course
if
not
has_access
(
request
.
user
,
item_location
):
raise
PermissionDenied
()
# optional parameter to delete all children (default False)
delete_children
=
False
if
'delete_children'
in
request
.
POST
:
delete_children
=
request
.
POST
[
'delete_children'
]
in
[
'true'
,
'True'
]
item
=
modulestore
()
.
get_item
(
item_location
)
_delete_item
(
item
)
return
HttpResponse
()
...
...
cms/static/js/base.js
View file @
5390a19f
...
...
@@ -20,8 +20,24 @@ $(document).ready(function() {
$
(
'.unit-history ol a'
).
bind
(
'click'
,
showHistoryModal
);
$modal
.
bind
(
'click'
,
hideHistoryModal
);
$modalCover
.
bind
(
'click'
,
hideHistoryModal
);
$
(
'.unit .item-actions .delete-button'
).
bind
(
'click'
,
deleteUnit
);
});
function
deleteUnit
(
e
)
{
e
.
preventDefault
();
var
id
=
$
(
this
).
data
(
'id'
);
var
_this
=
$
(
this
);
$
.
post
(
'/delete_item'
,
{
'id'
:
id
,
'delete_children'
:
'true'
},
function
(
data
)
{
// remove 'leaf' class containing <li> element
var
parent
=
_this
.
parents
(
'li.leaf'
);
parent
.
remove
();
});
}
function
toggleSubmodules
(
e
)
{
e
.
preventDefault
();
$
(
this
).
toggleClass
(
'expand'
).
toggleClass
(
'collapse'
);
...
...
cms/templates/widgets/units.html
View file @
5390a19f
...
...
@@ -6,13 +6,13 @@ This def will enumerate through a passed in subsection and list all of the units
<
%
def
name=
"enum_units(subsection)"
>
<ol>
% for unit in subsection.get_children():
<li
class=
"leaf"
>
<li
class=
"leaf
unit
"
>
<div
class=
"section-item"
>
<a
href=
"${reverse('edit_unit', args=[unit.location])}"
class=
"private-item"
>
<span
class=
"${unit.category}-icon"
></span>
${unit.display_name}
<span
class=
"private-tag"
>
- private
</span>
</a>
<div
class=
"item-actions"
>
<a
href=
"
${reverse('delete_unit', args=[unit.location])}"
classs=
"edit-button wip
"
><span
class=
"delete-icon"
></span></a>
<a
href=
"
#"
class=
"delete-button"
data-id=
"${unit.location}
"
><span
class=
"delete-icon"
></span></a>
<a
href=
"#"
class=
"drag-handle wip"
></a>
</div>
</div>
...
...
@@ -25,3 +25,6 @@ This def will enumerate through a passed in subsection and list all of the units
</li>
</ol>
</
%
def>
cms/urls.py
View file @
5390a19f
...
...
@@ -11,7 +11,6 @@ urlpatterns = ('',
url
(
r'^$'
,
'contentstore.views.index'
,
name
=
'index'
),
url
(
r'^edit/(?P<location>.*?)$'
,
'contentstore.views.edit_unit'
,
name
=
'edit_unit'
),
url
(
r'^subsection/(?P<location>.*?)$'
,
'contentstore.views.edit_subsection'
,
name
=
'edit_subsection'
),
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'
),
...
...
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