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
9b749c42
Commit
9b749c42
authored
Jun 13, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ajax callback entry point to remove the asset
parent
3fa6e77d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
cms/djangoapps/contentstore/views/assets.py
+51
-0
cms/urls.py
+5
-0
No files found.
cms/djangoapps/contentstore/views/assets.py
View file @
9b749c42
...
...
@@ -25,6 +25,8 @@ from xmodule.modulestore.django import modulestore
from
xmodule.modulestore
import
Location
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.util.date_utils
import
get_default_time_display
from
xmodule.modulestore
import
InvalidLocationError
from
xmodule.exceptions
import
NotFoundError
from
..utils
import
get_url_reverse
from
.access
import
get_location_and_verify_access
...
...
@@ -82,6 +84,8 @@ def asset_index(request, org, course, name):
})
@login_required
@ensure_csrf_cookie
def
upload_asset
(
request
,
org
,
course
,
coursename
):
'''
cdodge: this method allows for POST uploading of files into the course asset library, which will
...
...
@@ -147,6 +151,53 @@ def upload_asset(request, org, course, coursename):
@ensure_csrf_cookie
@login_required
def
remove_asset
(
request
,
org
,
course
,
name
,
location
):
'''
This method will perform a 'soft-delete' of an asset, which is basically to copy the asset from
the main GridFS collection and into a Trashcan
'''
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
# make sure the location is valid
try
:
loc
=
StaticContent
.
get_location_from_path
(
request
.
path
)
except
InvalidLocationError
:
# return a 'Bad Request' to browser as we have a malformed Location
response
=
HttpResponse
()
response
.
status_code
=
400
return
response
# also make sure the item to delete actually exists
try
:
content
=
contentstore
()
.
find
(
loc
)
except
NotFoundError
:
response
=
HttpResponse
()
response
.
status_code
=
404
return
response
# ok, save the content into the trashcan
contentstore
(
'trashcan'
)
.
save
(
content
)
# see if there is a thumbnail as well, if so move that as well
if
content
.
thumbnail_location
is
not
None
:
try
:
thumbnail_content
=
contentstore
()
.
find
(
content
.
thumbnail_location
)
contentstore
(
'trashcan'
)
.
save
(
thumbnail_content
)
# hard delete thumbnail from origin
contentstore
()
.
delete
(
thumbnail_content
.
get_id
())
# remove from any caching
del_cached_content
(
thumbnail_content
.
location
)
except
:
pass
# OK if this is left dangling
# delete the original
contentstore
()
.
delete
(
content
.
get_id
())
# remove from cache
del_cached_content
(
content
.
location
)
@ensure_csrf_cookie
@login_required
def
import_course
(
request
,
org
,
course
,
name
):
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
...
...
cms/urls.py
View file @
9b749c42
...
...
@@ -35,6 +35,8 @@ urlpatterns = ('', # nopep8
'contentstore.views.preview_dispatch'
,
name
=
'preview_dispatch'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<coursename>[^/]+)/upload_asset$'
,
'contentstore.views.upload_asset'
,
name
=
'upload_asset'
),
url
(
r'^manage_users/(?P<location>.*?)$'
,
'contentstore.views.manage_users'
,
name
=
'manage_users'
),
url
(
r'^add_user/(?P<location>.*?)$'
,
'contentstore.views.add_user'
,
name
=
'add_user'
),
...
...
@@ -71,8 +73,11 @@ urlpatterns = ('', # nopep8
'contentstore.views.edit_static'
,
name
=
'edit_static'
),
url
(
r'^edit_tabs/(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<coursename>[^/]+)$'
,
'contentstore.views.edit_tabs'
,
name
=
'edit_tabs'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/assets/(?P<name>[^/]+)$'
,
'contentstore.views.asset_index'
,
name
=
'asset_index'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/assets/remove/(?P<location>.*?)$'
,
'contentstore.views.remove_asset'
,
name
=
'remove_asset'
),
# this is a generic method to return the data/metadata associated with a xmodule
url
(
r'^module_info/(?P<module_location>.*)$'
,
...
...
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