-
Notifications
You must be signed in to change notification settings - Fork 4.2k
basic tab attach uploads with edx_video_id #18032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,19 +169,22 @@ def validate_transcript_upload_data(request): | |
| error, validated_data = None, {} | ||
| data, files = request.POST, request.FILES | ||
| video_locator = data.get('locator') | ||
| edx_video_id = data.get('edx_video_id') | ||
| if not video_locator: | ||
| error = _(u'Video locator is required.') | ||
| elif 'transcript-file' not in files: | ||
| error = _(u'A transcript file is required.') | ||
| elif os.path.splitext(files['transcript-file'].name)[1][1:] != Transcript.SRT: | ||
| error = _(u'This transcript file type is not supported.') | ||
| elif 'edx_video_id' not in data: | ||
| error = _(u'Video ID is required.') | ||
|
|
||
| if not error: | ||
| error, video = validate_video_module(request, video_locator) | ||
| if not error: | ||
| validated_data.update({ | ||
| 'video': video, | ||
| 'edx_video_id': clean_video_id(video.edx_video_id), | ||
| 'edx_video_id': clean_video_id(edx_video_id) or clean_video_id(video.edx_video_id), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we have success scenario test written for |
||
| 'transcript_file': files['transcript-file'] | ||
| }) | ||
|
|
||
|
|
@@ -212,6 +215,8 @@ def upload_transcripts(request): | |
| video.edx_video_id = edx_video_id | ||
| video.save_with_metadata(request.user) | ||
|
|
||
| response = JsonResponse({'edx_video_id': edx_video_id, 'status': 'Success'}, status=200) | ||
|
|
||
| try: | ||
| # Convert 'srt' transcript into the 'sjson' and upload it to | ||
| # configured transcript storage. For example, S3. | ||
|
|
@@ -220,7 +225,7 @@ def upload_transcripts(request): | |
| input_format=Transcript.SRT, | ||
| output_format=Transcript.SJSON | ||
| ) | ||
| create_or_update_video_transcript( | ||
| transcript_created = create_or_update_video_transcript( | ||
| video_id=edx_video_id, | ||
| language_code=u'en', | ||
| metadata={ | ||
|
|
@@ -230,7 +235,9 @@ def upload_transcripts(request): | |
| }, | ||
| file_data=ContentFile(sjson_subs), | ||
| ) | ||
| response = JsonResponse({'edx_video_id': edx_video_id, 'status': 'Success'}, status=200) | ||
|
|
||
| if transcript_created is None: | ||
| response = JsonResponse({'status': 'Invalid Video ID'}, status=400) | ||
|
|
||
| except (TranscriptsGenerationException, UnicodeDecodeError): | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ define( | |
| 'jquery', 'backbone', 'underscore', | ||
| 'js/views/video/transcripts/utils' | ||
| ], | ||
| function($, Backbone, _, Utils) { | ||
| function($, Backbone, _, TranscriptUtils) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wasn't previously being used ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
| var FileUploader = Backbone.View.extend({ | ||
| invisibleClass: 'is-invisible', | ||
|
|
||
|
|
@@ -57,14 +57,19 @@ function($, Backbone, _, Utils) { | |
| * | ||
| */ | ||
| upload: function() { | ||
| var data = { | ||
| 'edx_video_id': TranscriptUtils.Storage.get('edx_video_id') || '' | ||
| }; | ||
|
|
||
| if (!this.file) { | ||
| return; | ||
| } | ||
|
|
||
| this.$form.ajaxSubmit({ | ||
| beforeSend: this.xhrResetProgressBar, | ||
| uploadProgress: this.xhrProgressHandler, | ||
| complete: this.xhrCompleteHandler | ||
| complete: this.xhrCompleteHandler, | ||
| data: data | ||
| }); | ||
| }, | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍