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
c51bcdbf
Commit
c51bcdbf
authored
Feb 08, 2016
by
sanfordstudent
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11418 from edx/sstudent/MA-1918-handle-no-handouts
MA-1918 returning None for courses with no handouts
parents
74bdef1e
f88e5bc1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
10 deletions
+26
-10
lms/djangoapps/mobile_api/course_info/tests.py
+13
-1
lms/djangoapps/mobile_api/course_info/views.py
+13
-9
No files found.
lms/djangoapps/mobile_api/course_info/tests.py
View file @
c51bcdbf
...
...
@@ -116,7 +116,19 @@ class TestHandouts(MobileAPITestCase, MobileAuthTestMixin, MobileCourseAccessTes
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
self
.
course
.
id
):
self
.
store
.
delete_item
(
handouts_usage_key
,
self
.
user
.
id
)
self
.
api_response
(
expected_response_code
=
404
)
response
=
self
.
api_response
(
expected_response_code
=
200
)
self
.
assertIsNone
(
response
.
data
[
'handouts_html'
])
def
test_empty_handouts
(
self
):
self
.
login_and_enroll
()
# set handouts to empty tags
handouts_usage_key
=
self
.
course
.
id
.
make_usage_key
(
'course_info'
,
'handouts'
)
underlying_handouts
=
self
.
store
.
get_item
(
handouts_usage_key
)
underlying_handouts
.
data
=
"<ol></ol>"
self
.
store
.
update_item
(
underlying_handouts
,
self
.
user
.
id
)
response
=
self
.
api_response
(
expected_response_code
=
200
)
self
.
assertIsNone
(
response
.
data
[
'handouts_html'
])
def
test_handouts_static_rewrites
(
self
):
self
.
login_and_enroll
()
...
...
lms/djangoapps/mobile_api/course_info/views.py
View file @
c51bcdbf
...
...
@@ -21,7 +21,7 @@ class CourseUpdatesList(generics.ListAPIView):
**Example Request**
GET /api/mobile/v0.5/course_info/{
organization}/{course_number}/{course_run
}/updates
GET /api/mobile/v0.5/course_info/{
course_id
}/updates
**Response Values**
...
...
@@ -65,7 +65,7 @@ class CourseHandoutsList(generics.ListAPIView):
**Example Request**
GET /api/mobile/v0.5/course_info/{
organization}/{course_number}/{course_run
}/handouts
GET /api/mobile/v0.5/course_info/{
course_id
}/handouts
**Response Values**
...
...
@@ -79,13 +79,17 @@ class CourseHandoutsList(generics.ListAPIView):
def
list
(
self
,
request
,
course
,
*
args
,
**
kwargs
):
course_handouts_module
=
get_course_info_section_module
(
request
,
request
.
user
,
course
,
'handouts'
)
if
course_handouts_module
:
handouts_html
=
course_handouts_module
.
data
handouts_html
=
replace_static_urls
(
handouts_html
,
course_id
=
course
.
id
,
static_asset_path
=
course
.
static_asset_path
)
handouts_html
=
make_static_urls_absolute
(
self
.
request
,
handouts_html
)
if
course_handouts_module
.
data
==
"<ol></ol>"
:
handouts_html
=
None
else
:
handouts_html
=
course_handouts_module
.
data
handouts_html
=
replace_static_urls
(
handouts_html
,
course_id
=
course
.
id
,
static_asset_path
=
course
.
static_asset_path
)
handouts_html
=
make_static_urls_absolute
(
self
.
request
,
handouts_html
)
return
Response
({
'handouts_html'
:
handouts_html
})
else
:
# course_handouts_module could be None if there are no handouts
r
aise
Http404
(
u"No handouts for {}"
.
format
(
unicode
(
course
.
id
))
)
r
eturn
Response
({
'handouts_html'
:
None
}
)
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