Commit 333842a3 by Mushtaq Ali

Add the functionality behind feature flag

parent ccf76b3b
...@@ -527,17 +527,19 @@ def _get_videos(course): ...@@ -527,17 +527,19 @@ def _get_videos(course):
""" """
Retrieves the list of videos from VAL corresponding to this course. Retrieves the list of videos from VAL corresponding to this course.
""" """
is_video_transcript_enabled = VideoTranscriptEnabledFlag.feature_enabled(course.id)
videos = list(get_videos_for_course(unicode(course.id), VideoSortField.created, SortDirection.desc)) videos = list(get_videos_for_course(unicode(course.id), VideoSortField.created, SortDirection.desc))
# convert VAL's status to studio's Video Upload feature status. # convert VAL's status to studio's Video Upload feature status.
for video in videos: for video in videos:
video["status"] = convert_video_status(video) video["status"] = convert_video_status(video)
transcripts = {} if is_video_transcript_enabled:
for lang_code in get_available_transcript_languages([video['edx_video_id']]): transcripts = {}
transcripts.update({lang_code: get_all_transcript_languages()[lang_code]}) for lang_code in get_available_transcript_languages([video['edx_video_id']]):
transcripts.update({lang_code: get_all_transcript_languages(is_video_transcript_enabled)[lang_code]})
video['transcripts'] = transcripts video['transcripts'] = transcripts
return videos return videos
...@@ -554,7 +556,10 @@ def _get_index_videos(course): ...@@ -554,7 +556,10 @@ def _get_index_videos(course):
Returns the information about each video upload required for the video list Returns the information about each video upload required for the video list
""" """
course_id = unicode(course.id) course_id = unicode(course.id)
attrs = ['edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'courses', 'transcripts'] attrs = ['edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'courses']
if VideoTranscriptEnabledFlag.feature_enabled(course.id):
attrs += ['transcripts']
def _get_values(video): def _get_values(video):
""" """
...@@ -574,18 +579,20 @@ def _get_index_videos(course): ...@@ -574,18 +579,20 @@ def _get_index_videos(course):
_get_values(video) for video in _get_videos(course) _get_values(video) for video in _get_videos(course)
] ]
def get_all_transcript_languages(): def get_all_transcript_languages(is_video_transcript_enabled=False):
""" """
Returns all possible languages for transcript. Returns all possible languages for transcript.
""" """
transcription_plans = get_3rd_party_transcription_plans() third_party_transcription_languages = {}
cielo_fidelity = transcription_plans[TranscriptProvider.CIELO24]['fidelity'] if is_video_transcript_enabled:
transcription_plans = get_3rd_party_transcription_plans()
cielo_fidelity = transcription_plans[TranscriptProvider.CIELO24]['fidelity']
# Get third party transcription languages. # Get third party transcription languages.
third_party_transcription_languages = transcription_plans[TranscriptProvider.THREE_PLAY_MEDIA]['languages'] third_party_transcription_languages = transcription_plans[TranscriptProvider.THREE_PLAY_MEDIA]['languages']
third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['MECHANICAL']['languages']) third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['MECHANICAL']['languages'])
third_party_transcription_languages = dict(third_party_transcription_languages , **cielo_fidelity['PREMIUM']['languages']) third_party_transcription_languages = dict(third_party_transcription_languages , **cielo_fidelity['PREMIUM']['languages'])
third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['PROFESSIONAL']['languages']) third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['PROFESSIONAL']['languages'])
# Get all settings languages dict. # Get all settings languages dict.
all_languages = {} all_languages = {}
...@@ -622,7 +629,7 @@ def videos_index_html(course): ...@@ -622,7 +629,7 @@ def videos_index_html(course):
'video_transcript_settings': None, 'video_transcript_settings': None,
'active_transcript_preferences': None, 'active_transcript_preferences': None,
'transcript_credentials': None, 'transcript_credentials': None,
'transcript_available_languages': get_all_transcript_languages() 'transcript_available_languages': get_all_transcript_languages(is_video_transcript_enabled)
} }
if is_video_transcript_enabled: if is_video_transcript_enabled:
......
...@@ -54,7 +54,8 @@ define([ ...@@ -54,7 +54,8 @@ define([
encodingsDownloadUrl: encodingsDownloadUrl, encodingsDownloadUrl: encodingsDownloadUrl,
videoImageSettings: videoImageSettings, videoImageSettings: videoImageSettings,
transcriptAvailableLanguages: transcriptAvailableLanguages, transcriptAvailableLanguages: transcriptAvailableLanguages,
videoSupportedFileFormats: videoSupportedFileFormats videoSupportedFileFormats: videoSupportedFileFormats,
isVideoTranscriptEnabled: isVideoTranscriptEnabled
}); });
$contentWrapper.find('.wrapper-assets').replaceWith(updatedView.render().$el); $contentWrapper.find('.wrapper-assets').replaceWith(updatedView.render().$el);
}); });
...@@ -68,7 +69,8 @@ define([ ...@@ -68,7 +69,8 @@ define([
encodingsDownloadUrl: encodingsDownloadUrl, encodingsDownloadUrl: encodingsDownloadUrl,
videoImageSettings: videoImageSettings, videoImageSettings: videoImageSettings,
transcriptAvailableLanguages: transcriptAvailableLanguages, transcriptAvailableLanguages: transcriptAvailableLanguages,
videoSupportedFileFormats: videoSupportedFileFormats videoSupportedFileFormats: videoSupportedFileFormats,
isVideoTranscriptEnabled: isVideoTranscriptEnabled
}); });
$contentWrapper.append(activeView.render().$el); $contentWrapper.append(activeView.render().$el);
$contentWrapper.append(previousView.render().$el); $contentWrapper.append(previousView.render().$el);
......
...@@ -20,6 +20,7 @@ define( ...@@ -20,6 +20,7 @@ define(
this.template = HtmlUtils.template(previousVideoUploadTemplate); this.template = HtmlUtils.template(previousVideoUploadTemplate);
this.videoHandlerUrl = options.videoHandlerUrl; this.videoHandlerUrl = options.videoHandlerUrl;
this.videoImageUploadEnabled = options.videoImageSettings.video_image_upload_enabled; this.videoImageUploadEnabled = options.videoImageSettings.video_image_upload_enabled;
this.isVideoTranscriptEnabled = options.isVideoTranscriptEnabled;
if (this.videoImageUploadEnabled) { if (this.videoImageUploadEnabled) {
this.videoThumbnailView = new VideoThumbnailView({ this.videoThumbnailView = new VideoThumbnailView({
...@@ -29,18 +30,21 @@ define( ...@@ -29,18 +30,21 @@ define(
videoImageSettings: options.videoImageSettings videoImageSettings: options.videoImageSettings
}); });
} }
this.videoTranscriptsView = new VideoTranscriptsView({ if (this.isVideoTranscriptEnabled) {
transcripts: this.model.get('transcripts'), this.videoTranscriptsView = new VideoTranscriptsView({
edxVideoID: this.model.get('edx_video_id'), transcripts: this.model.get('transcripts'),
clientVideoID: this.model.get('client_video_id'), edxVideoID: this.model.get('edx_video_id'),
transcriptAvailableLanguages: options.transcriptAvailableLanguages, clientVideoID: this.model.get('client_video_id'),
videoSupportedFileFormats: options.videoSupportedFileFormats transcriptAvailableLanguages: options.transcriptAvailableLanguages,
}); videoSupportedFileFormats: options.videoSupportedFileFormats
});
}
}, },
render: function() { render: function() {
var renderedAttributes = { var renderedAttributes = {
videoImageUploadEnabled: this.videoImageUploadEnabled, videoImageUploadEnabled: this.videoImageUploadEnabled,
isVideoTranscriptEnabled: this.isVideoTranscriptEnabled,
created: DateUtils.renderDate(this.model.get('created')), created: DateUtils.renderDate(this.model.get('created')),
status: this.model.get('status') status: this.model.get('status')
}; };
...@@ -54,7 +58,9 @@ define( ...@@ -54,7 +58,9 @@ define(
if (this.videoImageUploadEnabled) { if (this.videoImageUploadEnabled) {
this.videoThumbnailView.setElement(this.$('.thumbnail-col')).render(); this.videoThumbnailView.setElement(this.$('.thumbnail-col')).render();
} }
this.videoTranscriptsView.setElement(this.$('.transcripts-col')).render(); if (this.isVideoTranscriptEnabled) {
this.videoTranscriptsView.setElement(this.$('.transcripts-col')).render();
}
return this; return this;
}, },
......
...@@ -10,6 +10,7 @@ define( ...@@ -10,6 +10,7 @@ define(
this.template = this.loadTemplate('previous-video-upload-list'); this.template = this.loadTemplate('previous-video-upload-list');
this.encodingsDownloadUrl = options.encodingsDownloadUrl; this.encodingsDownloadUrl = options.encodingsDownloadUrl;
this.videoImageUploadEnabled = options.videoImageSettings.video_image_upload_enabled; this.videoImageUploadEnabled = options.videoImageSettings.video_image_upload_enabled;
this.isVideoTranscriptEnabled = options.isVideoTranscriptEnabled;
this.itemViews = this.collection.map(function(model) { this.itemViews = this.collection.map(function(model) {
return new PreviousVideoUploadView({ return new PreviousVideoUploadView({
videoImageUploadURL: options.videoImageUploadURL, videoImageUploadURL: options.videoImageUploadURL,
...@@ -18,7 +19,8 @@ define( ...@@ -18,7 +19,8 @@ define(
videoImageSettings: options.videoImageSettings, videoImageSettings: options.videoImageSettings,
model: model, model: model,
transcriptAvailableLanguages: options.transcriptAvailableLanguages, transcriptAvailableLanguages: options.transcriptAvailableLanguages,
videoSupportedFileFormats: options.videoSupportedFileFormats videoSupportedFileFormats: options.videoSupportedFileFormats,
isVideoTranscriptEnabled: options.isVideoTranscriptEnabled
}); });
}); });
}, },
...@@ -28,7 +30,8 @@ define( ...@@ -28,7 +30,8 @@ define(
$tabBody; $tabBody;
$el.html(this.template({ $el.html(this.template({
encodingsDownloadUrl: this.encodingsDownloadUrl, encodingsDownloadUrl: this.encodingsDownloadUrl,
videoImageUploadEnabled: this.videoImageUploadEnabled videoImageUploadEnabled: this.videoImageUploadEnabled,
isVideoTranscriptEnabled: this.isVideoTranscriptEnabled
})); }));
$tabBody = $el.find('.js-table-body'); $tabBody = $el.find('.js-table-body');
_.each(this.itemViews, function(view) { _.each(this.itemViews, function(view) {
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
<div class="video-head-col video-col name-col"><%- gettext("Name") %></div> <div class="video-head-col video-col name-col"><%- gettext("Name") %></div>
<div class="video-head-col video-col date-col"><%- gettext("Date Added") %></div> <div class="video-head-col video-col date-col"><%- gettext("Date Added") %></div>
<div class="video-head-col video-col video-id-col"><%- gettext("Video ID") %></div> <div class="video-head-col video-col video-id-col"><%- gettext("Video ID") %></div>
<% if (isVideoTranscriptEnabled) { %>
<div class="video-head-col video-col transcripts-col"><%- gettext("Transcripts") %></div> <div class="video-head-col video-col transcripts-col"><%- gettext("Transcripts") %></div>
<% } %>
<div class="video-head-col video-col status-col"><%- gettext("Status") %></div> <div class="video-head-col video-col status-col"><%- gettext("Status") %></div>
<div class="video-head-col video-col actions-col"><%- gettext("Action") %></div> <div class="video-head-col video-col actions-col"><%- gettext("Action") %></div>
</div> </div>
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
<div class="video-col name-col"><%- client_video_id %></div> <div class="video-col name-col"><%- client_video_id %></div>
<div class="video-col date-col"><%- created %></div> <div class="video-col date-col"><%- created %></div>
<div class="video-col video-id-col"><%- edx_video_id %></div> <div class="video-col video-id-col"><%- edx_video_id %></div>
<% if (isVideoTranscriptEnabled) { %>
<div class="video-col transcripts-col"></div> <div class="video-col transcripts-col"></div>
<% } %>
<div class="video-col status-col"><%- status %> </div> <div class="video-col status-col"><%- status %> </div>
<div class="video-col actions-col"> <div class="video-col actions-col">
<ul class="actions-list"> <ul class="actions-list">
......
...@@ -35,4 +35,4 @@ ...@@ -35,4 +35,4 @@
</div> </div>
</div> </div>
<% }) %> <% }) %>
</div> </div>
\ No newline at end of file
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