Commit 333842a3 by Mushtaq Ali

Add the functionality behind feature flag

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