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
e9c70633
Commit
e9c70633
authored
Oct 08, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add delete if staff member
parent
6b979752
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
cms/djangoapps/contentstore/tests/test_orphan.py
+14
-0
cms/djangoapps/contentstore/views/item.py
+7
-1
No files found.
cms/djangoapps/contentstore/tests/test_orphan.py
View file @
e9c70633
...
...
@@ -56,3 +56,17 @@ class TestOrphan(CourseTestCase):
self
.
assertIn
(
location
.
url
(),
orphans
)
location
=
self
.
course
.
location
.
replace
(
category
=
'html'
,
name
=
'OrphanHtml'
)
self
.
assertIn
(
location
.
url
(),
orphans
)
def
test_mongo_orphan_delete
(
self
):
"""
Test that old mongo deletes the orphans
"""
url
=
reverse
(
'orphan'
,
kwargs
=
{
'course_id'
:
'{}.{}'
.
format
(
self
.
course
.
location
.
org
,
self
.
course
.
location
.
course
)}
)
self
.
client
.
delete
(
url
)
orphans
=
json
.
loads
(
self
.
client
.
get
(
url
,
HTTP_ACCEPT
=
'application/json'
)
.
content
)
self
.
assertEqual
(
len
(
orphans
),
0
,
"Orphans not deleted {}"
.
format
(
orphans
))
cms/djangoapps/contentstore/views/item.py
View file @
e9c70633
...
...
@@ -20,6 +20,7 @@ from ..utils import get_modulestore
from
.access
import
has_access
from
.helpers
import
_xmodule_recurse
from
xmodule.x_module
import
XModuleDescriptor
from
django.views.decorators.http
import
require_http_methods
__all__
=
[
'save_item'
,
'create_item'
,
'delete_item'
,
'orphan'
]
...
...
@@ -203,6 +204,7 @@ def delete_item(request):
@login_required
@require_http_methods
((
"GET"
,
"DELETE"
))
def
orphan
(
request
,
course_id
):
"""
View for handling orphan related requests. A get gets all of the current orphans.
...
...
@@ -214,6 +216,10 @@ def orphan(request, course_id):
:param request:
:param course_id: Locator syntax course_id
"""
# dhm: I'd add DELETE but I'm not sure what type of authentication/authorization we'd need
if
request
.
method
==
'GET'
:
return
JsonResponse
(
modulestore
()
.
get_orphans
(
course_id
,
DETACHED_CATEGORIES
,
'draft'
))
if
request
.
method
==
'DELETE'
and
request
.
user
.
is_staff
:
items
=
modulestore
()
.
get_orphans
(
course_id
,
DETACHED_CATEGORIES
,
'draft'
)
for
item
in
items
:
modulestore
(
'draft'
)
.
delete_item
(
item
,
True
)
return
JsonResponse
({
'deleted'
:
items
})
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