diff --git a/cms/djangoapps/contentstore/rest_api/v1/serializers/videos.py b/cms/djangoapps/contentstore/rest_api/v1/serializers/videos.py index 04f508eedf..c5e730d127 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/serializers/videos.py +++ b/cms/djangoapps/contentstore/rest_api/v1/serializers/videos.py @@ -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() diff --git a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_videos.py b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_videos.py index d5d277c498..993072e071 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_videos.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_videos.py @@ -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"]) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index 8e3f97eee9..112431b612 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -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(), diff --git a/openedx/core/djangoapps/video_config/toggles.py b/openedx/core/djangoapps/video_config/toggles.py index f417537b54..9569a00edd 100644 --- a/openedx/core/djangoapps/video_config/toggles.py +++ b/openedx/core/djangoapps/video_config/toggles.py @@ -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)