Merge pull request #33876 from openedx/hajorg/nova-50-use-xpert-translations-waffle-flag
feat: add is_ai_translations_enabled to get_course_videos_context util
This commit is contained in:
@@ -89,6 +89,7 @@ class CourseVideosSerializer(serializers.Serializer):
|
||||
video_upload_max_file_size = serializers.CharField()
|
||||
video_image_settings = VideoImageSettingsSerializer(required=True, allow_null=False)
|
||||
is_video_transcript_enabled = serializers.BooleanField()
|
||||
is_ai_translations_enabled = serializers.BooleanField()
|
||||
active_transcript_preferences = VideoActiveTranscriptPreferencesSerializer(required=False, allow_null=True)
|
||||
transcript_credentials = serializers.DictField(
|
||||
child=serializers.BooleanField()
|
||||
|
||||
@@ -56,6 +56,7 @@ class CourseVideosViewTest(CourseTestCase, PermissionAccessMixin):
|
||||
"supported_file_formats": settings.VIDEO_IMAGE_SUPPORTED_FILE_FORMATS
|
||||
},
|
||||
"is_video_transcript_enabled": False,
|
||||
"is_ai_translations_enabled": False,
|
||||
"active_transcript_preferences": None,
|
||||
"transcript_credentials": None,
|
||||
"transcript_available_languages": get_all_transcript_languages(),
|
||||
@@ -126,3 +127,10 @@ class CourseVideosViewTest(CourseTestCase, PermissionAccessMixin):
|
||||
)
|
||||
self.assertIn("transcript_credentials_handler_url", transcript_settings)
|
||||
self.assertEqual(expected_credentials_handler, transcript_settings["transcript_credentials_handler_url"])
|
||||
with patch(
|
||||
'openedx.core.djangoapps.video_config.toggles.XPERT_TRANSLATIONS_UI.is_enabled'
|
||||
) as xpertTranslationfeature:
|
||||
xpertTranslationfeature.return_value = True
|
||||
response = self.client.get(self.url)
|
||||
self.assertIn("is_ai_translations_enabled", response.data)
|
||||
self.assertTrue(response.data["is_ai_translations_enabled"])
|
||||
|
||||
@@ -77,6 +77,7 @@ from cms.djangoapps.contentstore.toggles import (
|
||||
use_new_video_uploads_page,
|
||||
use_new_custom_pages,
|
||||
use_tagging_taxonomy_list_page,
|
||||
# use_xpert_translations_component,
|
||||
)
|
||||
from cms.djangoapps.models.settings.course_grading import CourseGradingModel
|
||||
from xmodule.library_tools import LibraryToolsService
|
||||
@@ -1595,6 +1596,7 @@ def get_course_videos_context(course_block, pagination_conf, course_key=None):
|
||||
get_transcript_preferences,
|
||||
)
|
||||
from openedx.core.djangoapps.video_config.models import VideoTranscriptEnabledFlag
|
||||
from openedx.core.djangoapps.video_config.toggles import use_xpert_translations_component
|
||||
from xmodule.video_block.transcripts_utils import Transcript # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
from .video_storage_handlers import (
|
||||
@@ -1619,6 +1621,7 @@ def get_course_videos_context(course_block, pagination_conf, course_key=None):
|
||||
course = modulestore().get_course(course_key)
|
||||
|
||||
is_video_transcript_enabled = VideoTranscriptEnabledFlag.feature_enabled(course.id)
|
||||
is_ai_translations_enabled = use_xpert_translations_component(course.id)
|
||||
previous_uploads, pagination_context = _get_index_videos(course, pagination_conf)
|
||||
course_video_context = {
|
||||
'context_course': course,
|
||||
@@ -1639,6 +1642,7 @@ def get_course_videos_context(course_block, pagination_conf, course_key=None):
|
||||
'supported_file_formats': settings.VIDEO_IMAGE_SUPPORTED_FILE_FORMATS
|
||||
},
|
||||
'is_video_transcript_enabled': is_video_transcript_enabled,
|
||||
'is_ai_translations_enabled': is_ai_translations_enabled,
|
||||
'active_transcript_preferences': None,
|
||||
'transcript_credentials': None,
|
||||
'transcript_available_languages': get_all_transcript_languages(),
|
||||
|
||||
@@ -37,3 +37,10 @@ TRANSCRIPT_FEEDBACK = CourseWaffleFlag(
|
||||
XPERT_TRANSLATIONS_UI = CourseWaffleFlag(
|
||||
f'{WAFFLE_FLAG_NAMESPACE}.xpert_translations_ui', __name__
|
||||
)
|
||||
|
||||
|
||||
def use_xpert_translations_component(course_key):
|
||||
"""
|
||||
Returns a boolean if xpert translations ui component is enabled
|
||||
"""
|
||||
return XPERT_TRANSLATIONS_UI.is_enabled(course_key)
|
||||
|
||||
Reference in New Issue
Block a user