Fix bug affecting video transcripts in XMLModulesStore courses
This commit is contained in:
@@ -195,12 +195,21 @@ class VideoStudentViewHandlers(object):
|
||||
|
||||
if transcript_name:
|
||||
course_location = CourseDescriptor.id_to_location(self.course_id)
|
||||
course = self.descriptor.runtime.modulestore.get_item(course_location)
|
||||
if course.static_asset_path:
|
||||
|
||||
# Get the asset path for course
|
||||
asset_path = None
|
||||
if hasattr(self.descriptor.runtime, 'modulestore'):
|
||||
course = self.descriptor.runtime.modulestore.get_item(course_location)
|
||||
asset_path = course.static_asset_path
|
||||
else:
|
||||
# Handle XML Courses that don't have modulestore in the runtime
|
||||
asset_path = getattr(self.descriptor, 'data_dir', None)
|
||||
|
||||
if asset_path:
|
||||
response = Response(
|
||||
status=307,
|
||||
location='/static/{0}/{1}'.format(
|
||||
course.static_asset_path,
|
||||
asset_path,
|
||||
subs_filename(transcript_name, self.transcript_language)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -439,6 +439,42 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
|
||||
response = self.item.transcript(request=request, dispatch='translation/uk')
|
||||
self.assertEqual(response.status, '404 Not Found')
|
||||
|
||||
def test_xml_transcript(self):
|
||||
"""
|
||||
Set data_dir and remove runtime modulestore to simulate an XMLModuelStore course.
|
||||
Then run the same tests as static_asset_path run.
|
||||
"""
|
||||
# Simulate XMLModuleStore xmodule
|
||||
self.item_descriptor.data_dir = 'dummy/static'
|
||||
del self.item_descriptor.runtime.modulestore
|
||||
|
||||
self.assertFalse(self.course.static_asset_path)
|
||||
|
||||
# Test youtube style en
|
||||
request = Request.blank('/translation/en?videoId=12345')
|
||||
response = self.item.transcript(request=request, dispatch='translation/en')
|
||||
self.assertEqual(response.status, '307 Temporary Redirect')
|
||||
self.assertIn(
|
||||
('Location', '/static/dummy/static/subs_12345.srt.sjson'),
|
||||
response.headerlist
|
||||
)
|
||||
|
||||
# Test HTML5 video style
|
||||
self.item.sub = 'OEoXaMPEzfM'
|
||||
request = Request.blank('/translation/en')
|
||||
response = self.item.transcript(request=request, dispatch='translation/en')
|
||||
self.assertEqual(response.status, '307 Temporary Redirect')
|
||||
self.assertIn(
|
||||
('Location', '/static/dummy/static/subs_OEoXaMPEzfM.srt.sjson'),
|
||||
response.headerlist
|
||||
)
|
||||
|
||||
# Test different language to ensure we are just ignoring it since we can't
|
||||
# translate with static fallback
|
||||
request = Request.blank('/translation/uk')
|
||||
response = self.item.transcript(request=request, dispatch='translation/uk')
|
||||
self.assertEqual(response.status, '404 Not Found')
|
||||
|
||||
|
||||
class TestStudioTranscriptTranslationGetDispatch(TestVideo):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user