Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
de15848e
Commit
de15848e
authored
Mar 25, 2014
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2622 from edx/alex/fix_duplicate_code_in_transcripts_ajax
Remove duplicate code in transcripts_ajax.
parents
22205c35
c9e9f6e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
20 deletions
+11
-20
cms/djangoapps/contentstore/views/transcripts_ajax.py
+11
-20
No files found.
cms/djangoapps/contentstore/views/transcripts_ajax.py
View file @
de15848e
...
...
@@ -115,29 +115,20 @@ def upload_transcripts(request):
# Allow upload only if any video link is presented
if
video_list
:
sub_attr
=
source_subs_name
try
:
# Generate and save for 1.0 speed, will create subs_sub_attr.srt.sjson subtitles file in storage.
try
:
# Generate and save for 1.0 speed, will create subs_sub_attr.srt.sjson subtitles file in storage.
generate_subs_from_source
({
1
:
sub_attr
},
source_subs_ext
,
source_subs_filedata
,
item
)
except
TranscriptsGenerationException
as
e
:
return
error_response
(
response
,
e
.
message
)
statuses
=
{}
for
video_dict
in
video_list
:
video_name
=
video_dict
[
'video'
]
# We are creating transcripts for every video source,
# for the case that in future, some of video sources can be deleted.
statuses
[
video_name
]
=
copy_or_rename_transcript
(
video_name
,
sub_attr
,
item
,
user
=
request
.
user
)
try
:
# updates item.sub with `video_name` if it is successful.
for
video_dict
in
video_list
:
video_name
=
video_dict
[
'video'
]
# We are creating transcripts for every video source, if in future some of video sources would be deleted.
# Updates item.sub with `video_name` on success.
copy_or_rename_transcript
(
video_name
,
sub_attr
,
item
,
user
=
request
.
user
)
selected_name
=
video_name
# name to write to item.sub field, chosen at random.
except
NotFoundError
:
# subtitles file `sub_attr` is not presented in the system. Nothing to copy or rename.
return
error_response
(
response
,
"Can't find transcripts in storage for {}"
.
format
(
sub_attr
))
item
.
sub
=
selected_name
# write one of new subtitles names to item.sub attribute.
item
.
save_with_metadata
(
request
.
user
)
response
[
'subs'
]
=
item
.
sub
response
[
'status'
]
=
'Success'
response
[
'subs'
]
=
item
.
sub
response
[
'status'
]
=
'Success'
except
Exception
as
ex
:
return
error_response
(
response
,
ex
.
message
)
else
:
return
error_response
(
response
,
'Empty video sources.'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment