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
b14d2e9c
Commit
b14d2e9c
authored
Dec 06, 2017
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix video transcript model import before Django initialization occurs.
parent
941bc5cf
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
44 additions
and
35 deletions
+44
-35
cms/djangoapps/contentstore/views/tests/test_transcripts.py
+3
-3
cms/djangoapps/contentstore/views/transcripts_ajax.py
+3
-1
common/lib/xmodule/xmodule/video_module/__init__.py
+1
-2
common/lib/xmodule/xmodule/video_module/transcripts_model_utils.py
+14
-0
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
+0
-11
common/lib/xmodule/xmodule/video_module/video_handlers.py
+3
-2
common/lib/xmodule/xmodule/video_module/video_module.py
+3
-1
lms/djangoapps/courseware/tests/test_video_handlers.py
+8
-8
lms/djangoapps/courseware/tests/test_video_mongo.py
+2
-2
lms/djangoapps/mobile_api/video_outlines/serializers.py
+1
-1
lms/djangoapps/mobile_api/video_outlines/tests.py
+3
-3
lms/djangoapps/mobile_api/video_outlines/views.py
+3
-1
No files found.
cms/djangoapps/contentstore/views/tests/test_transcripts.py
View file @
b14d2e9c
...
...
@@ -526,7 +526,7 @@ class TestDownloadTranscripts(BaseTranscripts):
self
.
assertEqual
(
resp
.
status_code
,
404
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'xmodule.video_module.transcripts_utils.edxval_api.get_video_transcript_data'
)
def
test_download_fallback_transcript
(
self
,
mock_get_video_transcript_data
):
"""
...
...
@@ -567,7 +567,7 @@ class TestDownloadTranscripts(BaseTranscripts):
self
.
assertEqual
(
response
.
get
(
attribute
),
value
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
False
),
)
def
test_download_fallback_transcript_feature_disabled
(
self
):
...
...
@@ -829,7 +829,7 @@ class TestCheckTranscripts(BaseTranscripts):
(
False
,
'not_found'
)
)
@ddt.unpack
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
)
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
)
@patch
(
'xmodule.video_module.transcripts_utils.edxval_api.get_video_transcript_data'
,
Mock
(
return_value
=
True
))
def
test_command_for_fallback_transcript
(
self
,
feature_enabled
,
expected_command
,
video_transcript_feature
):
"""
...
...
cms/djangoapps/contentstore/views/transcripts_ajax.py
View file @
b14d2e9c
...
...
@@ -33,13 +33,15 @@ from xmodule.video_module.transcripts_utils import (
get_video_transcript_content
,
generate_subs_from_source
,
get_transcripts_from_youtube
,
is_val_transcript_feature_enabled_for_course
,
manage_video_subtitles_save
,
remove_subs_from_store
,
Transcript
,
TranscriptsRequestValidationException
,
youtube_video_transcript_name
,
)
from
xmodule.video_module.transcripts_model_utils
import
(
is_val_transcript_feature_enabled_for_course
)
__all__
=
[
'upload_transcripts'
,
...
...
common/lib/xmodule/xmodule/video_module/__init__.py
View file @
b14d2e9c
"""
Container for video module and it
'
s utils.
Container for video module and its utils.
"""
# Disable wildcard-import warnings.
# pylint: disable=wildcard-import
from
.transcripts_utils
import
*
...
...
common/lib/xmodule/xmodule/video_module/transcripts_model_utils.py
0 → 100644
View file @
b14d2e9c
"""
Utility functions for transcripts dealing with Django models.
"""
from
openedx.core.djangoapps.video_config.models
import
VideoTranscriptEnabledFlag
def
is_val_transcript_feature_enabled_for_course
(
course_id
):
"""
Get edx-val transcript feature flag
Arguments:
course_id(CourseKey): Course key identifying a course whose feature flag is being inspected.
"""
return
VideoTranscriptEnabledFlag
.
feature_enabled
(
course_id
=
course_id
)
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
View file @
b14d2e9c
...
...
@@ -12,7 +12,6 @@ from pysrt import SubRipTime, SubRipItem, SubRipFile
from
lxml
import
etree
from
HTMLParser
import
HTMLParser
from
openedx.core.djangoapps.video_config.models
import
VideoTranscriptEnabledFlag
from
xmodule.exceptions
import
NotFoundError
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.django
import
contentstore
...
...
@@ -500,16 +499,6 @@ def get_video_ids_info(edx_video_id, youtube_id_1_0, html5_sources):
return
external
,
video_ids
def
is_val_transcript_feature_enabled_for_course
(
course_id
):
"""
Get edx-val transcript feature flag
Arguments:
course_id(CourseKey): Course key identifying a course whose feature flag is being inspected.
"""
return
VideoTranscriptEnabledFlag
.
feature_enabled
(
course_id
=
course_id
)
def
get_video_transcript_content
(
language_code
,
edx_video_id
,
youtube_id_1_0
,
html5_sources
):
"""
Gets video transcript content, only if the corresponding feature flag is enabled for the given `course_id`.
...
...
common/lib/xmodule/xmodule/video_module/video_handlers.py
View file @
b14d2e9c
...
...
@@ -22,7 +22,6 @@ from .transcripts_utils import (
get_or_create_sjson
,
generate_sjson_for_all_speeds
,
get_video_transcript_content
,
is_val_transcript_feature_enabled_for_course
,
save_to_store
,
subs_filename
,
Transcript
,
...
...
@@ -30,7 +29,9 @@ from .transcripts_utils import (
TranscriptsGenerationException
,
youtube_speed_dict
,
)
from
.transcripts_model_utils
import
(
is_val_transcript_feature_enabled_for_course
)
log
=
logging
.
getLogger
(
__name__
)
...
...
common/lib/xmodule/xmodule/video_module/video_module.py
View file @
b14d2e9c
...
...
@@ -44,10 +44,12 @@ from .bumper_utils import bumperize
from
.transcripts_utils
import
(
get_html5_ids
,
get_video_ids_info
,
is_val_transcript_feature_enabled_for_course
,
Transcript
,
VideoTranscriptsMixin
,
)
from
.transcripts_model_utils
import
(
is_val_transcript_feature_enabled_for_course
)
from
.video_handlers
import
VideoStudentViewHandlers
,
VideoStudioViewHandlers
from
.video_utils
import
create_youtube_string
,
format_xml_exception_message
,
get_poster
,
rewrite_video_url
from
.video_xfields
import
VideoFields
...
...
lms/djangoapps/courseware/tests/test_video_handlers.py
View file @
b14d2e9c
...
...
@@ -248,7 +248,7 @@ class TestTranscriptAvailableTranslationsDispatch(TestVideo):
response
=
self
.
item
.
transcript
(
request
=
request
,
dispatch
=
'available_translations'
)
self
.
assertEqual
(
json
.
loads
(
response
.
body
),
[
'en'
,
'uk'
])
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'xmodule.video_module.transcripts_utils.get_available_transcript_languages'
)
@ddt.data
(
(
...
...
@@ -309,7 +309,7 @@ class TestTranscriptAvailableTranslationsDispatch(TestVideo):
self
.
assertItemsEqual
(
json
.
loads
(
response
.
body
),
result
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
False
),
)
@patch
(
'xmodule.video_module.transcripts_utils.edxval_api.get_available_transcript_languages'
)
...
...
@@ -365,7 +365,7 @@ class TestTranscriptAvailableTranslationsBumperDispatch(TestVideo):
@ddt.data
(
True
,
False
)
@patch
(
'xmodule.video_module.transcripts_utils.get_available_transcript_languages'
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
)
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
)
def
test_multiple_available_translations
(
self
,
feature_enabled
,
mock_val_video_transcript_feature
,
mock_get_transcript_languages
):
"""
...
...
@@ -459,7 +459,7 @@ class TestTranscriptDownloadDispatch(TestVideo):
self
.
assertEqual
(
response
.
headers
[
'Content-Disposition'
],
'attachment; filename="塞.srt"'
)
@patch
(
'xmodule.video_module.transcripts_utils.edxval_api.get_video_transcript_data'
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'xmodule.video_module.VideoModule.get_transcript'
,
Mock
(
side_effect
=
NotFoundError
))
def
test_download_fallback_transcript
(
self
,
mock_get_video_transcript_data
):
"""
...
...
@@ -493,7 +493,7 @@ class TestTranscriptDownloadDispatch(TestVideo):
self
.
assertEqual
(
response
.
headers
[
attribute
],
value
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
False
),
)
@patch
(
'xmodule.video_module.VideoModule.get_transcript'
,
Mock
(
side_effect
=
NotFoundError
))
...
...
@@ -740,7 +740,7 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
@patch
(
'xmodule.video_module.transcripts_utils.edxval_api.get_video_transcript_data'
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'xmodule.video_module.VideoModule.translation'
,
Mock
(
side_effect
=
NotFoundError
))
@patch
(
'xmodule.video_module.VideoModule.get_static_transcript'
,
Mock
(
return_value
=
Response
(
status
=
404
)))
def
test_translation_fallback_transcript
(
self
,
mock_get_video_transcript_data
):
...
...
@@ -774,7 +774,7 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
self
.
assertEqual
(
response
.
headers
[
attribute
],
value
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
False
),
)
@patch
(
'xmodule.video_module.VideoModule.translation'
,
Mock
(
side_effect
=
NotFoundError
))
...
...
@@ -790,7 +790,7 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
@ddt.data
(
True
,
False
)
@patch
(
'xmodule.video_module.transcripts_utils.edxval_api.get_video_transcript_data'
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
)
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
)
def
test_translations_bumper_transcript
(
self
,
feature_enabled
,
mock_val_video_transcript_feature
,
mock_get_video_transcript_data
):
"""
...
...
lms/djangoapps/courseware/tests/test_video_mongo.py
View file @
b14d2e9c
...
...
@@ -1467,7 +1467,7 @@ class TestVideoDescriptorStudentViewJson(TestCase):
({
'uk'
:
1
,
'de'
:
1
},
'en-subs'
,
[
'de'
,
'en'
],
[
'en'
,
'uk'
,
'de'
]),
)
@ddt.unpack
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'xmodule.video_module.transcripts_utils.edxval_api.get_available_transcript_languages'
)
def
test_student_view_with_val_transcripts_enabled
(
self
,
transcripts
,
english_sub
,
val_transcripts
,
expected_transcripts
,
mock_get_transcript_languages
):
...
...
@@ -1481,7 +1481,7 @@ class TestVideoDescriptorStudentViewJson(TestCase):
self
.
assertItemsEqual
(
student_view_response
[
'transcripts'
]
.
keys
(),
expected_transcripts
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
False
),
)
@patch
(
...
...
lms/djangoapps/mobile_api/video_outlines/serializers.py
View file @
b14d2e9c
...
...
@@ -11,7 +11,7 @@ from courseware.module_render import get_module_for_descriptor
from
util.module_utils
import
get_dynamic_descriptor_children
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.mongo.base
import
BLOCK_TYPES_WITH_CHILDREN
from
xmodule.video_module.transcripts_utils
import
is_val_transcript_feature_enabled_for_course
from
xmodule.video_module.transcripts_
model_
utils
import
is_val_transcript_feature_enabled_for_course
class
BlockOutline
(
object
):
...
...
lms/djangoapps/mobile_api/video_outlines/tests.py
View file @
b14d2e9c
...
...
@@ -887,7 +887,7 @@ class TestVideoSummaryList(TestVideoAPITestCase, MobileAuthTestMixin, MobileCour
({
'uk'
:
1
,
'de'
:
1
},
'en-subs'
,
[
'de'
,
'en'
],
[
'en'
,
'uk'
,
'de'
]),
)
@ddt.unpack
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
@patch
(
'xmodule.video_module.transcripts_utils.edxval_api.get_available_transcript_languages'
)
def
test_val_transcripts_with_feature_enabled
(
self
,
transcripts
,
english_sub
,
val_transcripts
,
expected_transcripts
,
mock_get_transcript_languages
):
...
...
@@ -939,7 +939,7 @@ class TestTranscriptsDetail(TestVideoAPITestCase, MobileAuthTestMixin, MobileCou
self
.
api_response
(
expected_response_code
=
200
,
lang
=
'en'
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
),
)
@patch
(
...
...
@@ -976,7 +976,7 @@ class TestTranscriptsDetail(TestVideoAPITestCase, MobileAuthTestMixin, MobileCou
self
.
assertEqual
(
response
.
get
(
attribute
),
value
)
@patch
(
'
xmodule.video_module.transcripts_uti
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
'
openedx.core.djangoapps.video_config.mode
ls.VideoTranscriptEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
False
),
)
@patch
(
...
...
lms/djangoapps/mobile_api/video_outlines/views.py
View file @
b14d2e9c
...
...
@@ -19,9 +19,11 @@ from xmodule.exceptions import NotFoundError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.video_module.transcripts_utils
import
(
get_video_transcript_content
,
is_val_transcript_feature_enabled_for_course
,
Transcript
,
)
from
xmodule.video_module.transcripts_model_utils
import
(
is_val_transcript_feature_enabled_for_course
)
from
..decorators
import
mobile_course_access
,
mobile_view
from
.serializers
import
BlockOutline
,
video_summary
...
...
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