MA-1918 returning None for courses with no handouts
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
raise Http404(u"No handouts for {}".format(unicode(course.id)))
|
||||
return Response({'handouts_html': None})
|
||||
|
||||
Reference in New Issue
Block a user