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
00b885de
Commit
00b885de
authored
Jun 11, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update pdf textbooks backend to respond to AJAX requests with JSON
parent
e607bc70
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
20 deletions
+31
-20
cms/djangoapps/contentstore/views/course.py
+31
-20
No files found.
cms/djangoapps/contentstore/views/course.py
View file @
00b885de
...
...
@@ -12,6 +12,8 @@ from django.core.urlresolvers import reverse
from
mitxmako.shortcuts
import
render_to_response
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.inheritance
import
own_metadata
from
xmodule.modulestore.exceptions
import
(
ItemNotFoundError
,
InvalidLocationError
)
from
xmodule.modulestore
import
Location
...
...
@@ -425,26 +427,35 @@ def textbook_index(request, org, course, name):
org, course, name: Attributes of the Location for the item to edit
"""
upload_asset_callback_url
=
reverse
(
'upload_asset'
,
kwargs
=
{
'org'
:
org
,
'course'
:
course
,
'coursename'
:
name
,
})
asset_index_url
=
reverse
(
'asset_index'
,
kwargs
=
{
'org'
:
org
,
'course'
:
course
,
'name'
:
name
,
})
course_reference
=
StaticContent
.
compute_location
(
org
,
course
,
name
)
assets_db_objs
=
contentstore
()
.
get_all_content_for_course
(
course_reference
)
store
=
contentstore
()
assets_db_objs
=
store
.
get_all_content_for_course
(
course_reference
)
assets_json_objs
=
assets_to_json_dict
(
assets_db_objs
)
assets_pdfs
=
[
asset
for
asset
in
assets_json_objs
if
asset
[
"path"
]
.
endswith
(
".pdf"
)]
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
course_obj
=
modulestore
()
.
get_item
(
location
,
depth
=
3
)
return
render_to_response
(
'textbooks.html'
,
{
'context_course'
:
course_obj
,
'course'
:
course_obj
,
'assets'
:
assets_json_objs
,
'upload_asset_callback_url'
:
upload_asset_callback_url
,
'asset_index_url'
:
asset_index_url
,
})
course_module
=
modulestore
()
.
get_item
(
location
,
depth
=
3
)
if
request
.
is_ajax
():
if
request
.
method
==
'GET'
:
return
HttpResponse
(
json
.
dumps
(
course_module
.
pdf_textbooks
),
content_type
=
"application/json"
)
elif
request
.
method
==
'POST'
:
store
.
update_metadata
(
course
.
location
,
own_metadata
(
request
.
POST
))
return
HttpResponse
(
''
,
content_type
=
"application/json"
,
status
=
201
)
else
:
upload_asset_callback_url
=
reverse
(
'upload_asset'
,
kwargs
=
{
'org'
:
org
,
'course'
:
course
,
'coursename'
:
name
,
})
asset_index_url
=
reverse
(
'asset_index'
,
kwargs
=
{
'org'
:
org
,
'course'
:
course
,
'name'
:
name
,
})
return
render_to_response
(
'textbooks.html'
,
{
'context_course'
:
course_module
,
'course'
:
course_module
,
'assets'
:
assets_pdfs
,
'upload_asset_callback_url'
:
upload_asset_callback_url
,
'asset_index_url'
:
asset_index_url
,
})
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