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
fe6ed085
Commit
fe6ed085
authored
Sep 19, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review feedback.
parent
d11c92d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
35 deletions
+34
-35
cms/djangoapps/contentstore/views/assets.py
+32
-33
cms/static/js/views/assets_view.js
+1
-1
cms/urls.py
+1
-1
No files found.
cms/djangoapps/contentstore/views/assets.py
View file @
fe6ed085
...
@@ -145,7 +145,7 @@ def upload_asset(request, org, course, coursename):
...
@@ -145,7 +145,7 @@ def upload_asset(request, org, course, coursename):
return
JsonResponse
(
response_payload
)
return
JsonResponse
(
response_payload
)
@require_http_methods
(
"DELETE"
)
@require_http_methods
(
(
"DELETE"
,)
)
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
def
update_asset
(
request
,
org
,
course
,
name
,
asset_id
):
def
update_asset
(
request
,
org
,
course
,
name
,
asset_id
):
...
@@ -158,40 +158,39 @@ def update_asset(request, org, course, name, asset_id):
...
@@ -158,40 +158,39 @@ def update_asset(request, org, course, name, asset_id):
"""
"""
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
if
request
.
method
==
'DELETE'
:
# make sure the location is valid
# make sure the location is valid
try
:
try
:
loc
=
StaticContent
.
get_location_from_path
(
asset_id
)
loc
=
StaticContent
.
get_location_from_path
(
asset_id
)
except
InvalidLocationError
as
err
:
except
InvalidLocationError
as
err
:
# return a 'Bad Request' to browser as we have a malformed Location
# return a 'Bad Request' to browser as we have a malformed Location
return
JsonResponse
({
"error"
:
err
.
message
},
status
=
400
)
return
JsonResponse
({
"error"
:
err
.
message
},
status
=
400
)
# also make sure the item to delete actually exists
try
:
content
=
contentstore
()
.
find
(
loc
)
except
NotFoundError
:
return
JsonResponse
(
status
=
404
)
# ok, save the content into the trashcan
contentstore
(
'trashcan'
)
.
save
(
content
)
# also make sure the item to delete actually exists
# see if there is a thumbnail as well, if so move that as well
if
content
.
thumbnail_location
is
not
None
:
try
:
try
:
content
=
contentstore
()
.
find
(
loc
)
thumbnail_content
=
contentstore
()
.
find
(
content
.
thumbnail_location
)
except
NotFoundError
:
contentstore
(
'trashcan'
)
.
save
(
thumbnail_content
)
return
JsonResponse
(
status
=
404
)
# hard delete thumbnail from origin
contentstore
()
.
delete
(
thumbnail_content
.
get_id
())
# ok, save the content into the trashcan
# remove from any caching
contentstore
(
'trashcan'
)
.
save
(
content
)
del_cached_content
(
thumbnail_content
.
location
)
except
:
# see if there is a thumbnail as well, if so move that as well
pass
# OK if this is left dangling
if
content
.
thumbnail_location
is
not
None
:
try
:
# delete the original
thumbnail_content
=
contentstore
()
.
find
(
content
.
thumbnail_location
)
contentstore
()
.
delete
(
content
.
get_id
())
contentstore
(
'trashcan'
)
.
save
(
thumbnail_content
)
# remove from cache
# hard delete thumbnail from origin
del_cached_content
(
content
.
location
)
contentstore
()
.
delete
(
thumbnail_content
.
get_id
())
return
JsonResponse
()
# 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
)
return
JsonResponse
()
def
_get_asset_json
(
display_name
,
date
,
location
,
thumbnail_location
):
def
_get_asset_json
(
display_name
,
date
,
location
,
thumbnail_location
):
...
...
cms/static/js/views/assets_view.js
View file @
fe6ed085
...
@@ -10,7 +10,7 @@ CMS.Views.Assets = Backbone.View.extend({
...
@@ -10,7 +10,7 @@ CMS.Views.Assets = Backbone.View.extend({
this
.
$el
.
empty
();
this
.
$el
.
empty
();
var
self
=
this
;
var
self
=
this
;
_
.
each
(
this
.
collection
.
models
,
this
.
collection
.
each
(
function
(
asset
)
{
function
(
asset
)
{
var
view
=
new
CMS
.
Views
.
Asset
({
model
:
asset
});
var
view
=
new
CMS
.
Views
.
Asset
({
model
:
asset
});
self
.
$el
.
append
(
view
.
render
().
el
);
self
.
$el
.
append
(
view
.
render
().
el
);
...
...
cms/urls.py
View file @
fe6ed085
...
@@ -76,7 +76,7 @@ urlpatterns = ('', # nopep8
...
@@ -76,7 +76,7 @@ urlpatterns = ('', # nopep8
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/assets/(?P<name>[^/]+)$'
,
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/assets/(?P<name>[^/]+)$'
,
'contentstore.views.asset_index'
,
name
=
'asset_index'
),
'contentstore.views.asset_index'
,
name
=
'asset_index'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/assets/(?P<name>[^/]+)/
update/
(?P<asset_id>.+)?.*$'
,
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/assets/(?P<name>[^/]+)/(?P<asset_id>.+)?.*$'
,
'contentstore.views.assets.update_asset'
,
name
=
'update_asset'
),
'contentstore.views.assets.update_asset'
,
name
=
'update_asset'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/textbooks/(?P<name>[^/]+)$'
,
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/textbooks/(?P<name>[^/]+)$'
,
'contentstore.views.textbook_index'
,
name
=
'textbook_index'
),
'contentstore.views.textbook_index'
,
name
=
'textbook_index'
),
...
...
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