Commit de637f32 by Carson Gee

Merge pull request #3725 from carsongee/cg/transcript_xmlmodulestore_fix

Fix bug affecting video transcripts in XMLModulesStore courses
parents a9649973 52d8317a
......@@ -195,12 +195,21 @@ class VideoStudentViewHandlers(object):
if transcript_name:
course_location = CourseDescriptor.id_to_location(self.course_id)
# Get the asset path for course
asset_path = None
if hasattr(self.descriptor.runtime, 'modulestore'):
course = self.descriptor.runtime.modulestore.get_item(course_location)
if course.static_asset_path:
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):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment