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
2682a14d
Commit
2682a14d
authored
Dec 04, 2013
by
Christina Roberts
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1790 from edx/christina/transcripts
Change video transcripts to use locators instead of locations.
parents
69899e24
5fdfc609
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
130 additions
and
138 deletions
+130
-138
cms/djangoapps/contentstore/tests/test_contentstore.py
+3
-6
cms/djangoapps/contentstore/tests/test_transcripts.py
+40
-40
cms/djangoapps/contentstore/views/component.py
+3
-7
cms/djangoapps/contentstore/views/transcripts_ajax.py
+49
-48
cms/static/js/spec/transcripts/file_uploader_spec.js
+1
-1
cms/static/js/spec/transcripts/message_manager_spec.js
+5
-5
cms/static/js/spec/transcripts/videolist_spec.js
+4
-4
cms/static/js/views/transcripts/editor.js
+8
-10
cms/static/js/views/transcripts/file_uploader.js
+1
-1
cms/static/js/views/transcripts/message_manager.js
+5
-5
cms/static/js/views/transcripts/metadata_videolist.js
+3
-3
cms/static/js/views/transcripts/utils.js
+3
-3
cms/templates/js/transcripts/file-upload.underscore
+1
-1
cms/templates/js/transcripts/messages/transcripts-found.underscore
+1
-1
cms/templates/js/transcripts/messages/transcripts-uploaded.underscore
+1
-1
cms/templates/unit.html
+2
-2
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
2682a14d
...
@@ -137,8 +137,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
...
@@ -137,8 +137,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
locator
=
loc_mapper
()
.
translate_location
(
course
.
location
.
course_id
,
descriptor
.
location
,
False
,
True
)
locator
=
loc_mapper
()
.
translate_location
(
course
.
location
.
course_id
,
descriptor
.
location
,
False
,
True
)
resp
=
self
.
client
.
get_html
(
locator
.
url_reverse
(
'unit'
))
resp
=
self
.
client
.
get_html
(
locator
.
url_reverse
(
'unit'
))
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# TODO: uncomment when video transcripts no longer require IDs.
_test_no_locations
(
self
,
resp
)
# _test_no_locations(self, resp)
for
expected
in
expected_types
:
for
expected
in
expected_types
:
self
.
assertIn
(
expected
,
resp
.
content
)
self
.
assertIn
(
expected
,
resp
.
content
)
...
@@ -1354,8 +1353,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
...
@@ -1354,8 +1353,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
unit_locator
=
loc_mapper
()
.
translate_location
(
course_id
,
descriptor
.
location
,
False
,
True
)
unit_locator
=
loc_mapper
()
.
translate_location
(
course_id
,
descriptor
.
location
,
False
,
True
)
resp
=
self
.
client
.
get_html
(
unit_locator
.
url_reverse
(
'unit'
))
resp
=
self
.
client
.
get_html
(
unit_locator
.
url_reverse
(
'unit'
))
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# TODO: uncomment when video transcripts no longer require IDs.
_test_no_locations
(
self
,
resp
)
# _test_no_locations(self, resp)
@override_settings
(
CONTENTSTORE
=
TEST_DATA_CONTENTSTORE
,
MODULESTORE
=
TEST_MODULESTORE
)
@override_settings
(
CONTENTSTORE
=
TEST_DATA_CONTENTSTORE
,
MODULESTORE
=
TEST_MODULESTORE
)
...
@@ -1682,8 +1680,7 @@ class ContentStoreTest(ModuleStoreTestCase):
...
@@ -1682,8 +1680,7 @@ class ContentStoreTest(ModuleStoreTestCase):
unit_locator
=
loc_mapper
()
.
translate_location
(
loc
.
course_id
,
unit_location
,
False
,
True
)
unit_locator
=
loc_mapper
()
.
translate_location
(
loc
.
course_id
,
unit_location
,
False
,
True
)
resp
=
self
.
client
.
get_html
(
unit_locator
.
url_reverse
(
'unit'
))
resp
=
self
.
client
.
get_html
(
unit_locator
.
url_reverse
(
'unit'
))
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# TODO: uncomment when video transcripts no longer require IDs.
_test_no_locations
(
self
,
resp
)
# _test_no_locations(self, resp)
def
delete_item
(
category
,
name
):
def
delete_item
(
category
,
name
):
""" Helper method for testing the deletion of an xblock item. """
""" Helper method for testing the deletion of an xblock item. """
...
...
cms/djangoapps/contentstore/tests/test_transcripts.py
View file @
2682a14d
...
@@ -60,7 +60,7 @@ class Basetranscripts(CourseTestCase):
...
@@ -60,7 +60,7 @@ class Basetranscripts(CourseTestCase):
'type'
:
'video'
'type'
:
'video'
}
}
resp
=
self
.
client
.
ajax_post
(
'/xblock'
,
data
)
resp
=
self
.
client
.
ajax_post
(
'/xblock'
,
data
)
self
.
item_locat
ion
=
self
.
_get_location
(
resp
)
self
.
item_locat
or
,
self
.
item_location
=
self
.
_get_locator
(
resp
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# hI10vDNYz4M - valid Youtube ID with transcripts.
# hI10vDNYz4M - valid Youtube ID with transcripts.
...
@@ -73,10 +73,10 @@ class Basetranscripts(CourseTestCase):
...
@@ -73,10 +73,10 @@ class Basetranscripts(CourseTestCase):
# Remove all transcripts for current module.
# Remove all transcripts for current module.
self
.
clear_subs_content
()
self
.
clear_subs_content
()
def
_get_locat
ion
(
self
,
resp
):
def
_get_locat
or
(
self
,
resp
):
""" Returns the location (as a string) from the response returned by a create operation. """
""" Returns the locat
or and old-style locat
ion (as a string) from the response returned by a create operation. """
locator
=
json
.
loads
(
resp
.
content
)
.
get
(
'locator'
)
locator
=
json
.
loads
(
resp
.
content
)
.
get
(
'locator'
)
return
loc_mapper
()
.
translate_locator_to_location
(
BlockUsageLocator
(
locator
))
.
url
()
return
loc
ator
,
loc
_mapper
()
.
translate_locator_to_location
(
BlockUsageLocator
(
locator
))
.
url
()
def
get_youtube_ids
(
self
):
def
get_youtube_ids
(
self
):
"""Return youtube speeds and ids."""
"""Return youtube speeds and ids."""
...
@@ -142,7 +142,7 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -142,7 +142,7 @@ class TestUploadtranscripts(Basetranscripts):
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
resp
=
self
.
client
.
post
(
link
,
{
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
self
.
item_location
,
'
locator'
:
self
.
item_locator
,
'file'
:
self
.
good_srt_file
,
'file'
:
self
.
good_srt_file
,
'video_list'
:
json
.
dumps
([{
'video_list'
:
json
.
dumps
([{
'type'
:
'html5'
,
'type'
:
'html5'
,
...
@@ -164,20 +164,20 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -164,20 +164,20 @@ class TestUploadtranscripts(Basetranscripts):
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
resp
=
self
.
client
.
post
(
link
,
{
'file'
:
self
.
good_srt_file
})
resp
=
self
.
client
.
post
(
link
,
{
'file'
:
self
.
good_srt_file
})
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
'POST data without "
id
" form data.'
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
'POST data without "
locator
" form data.'
)
def
test_fail_data_without_file
(
self
):
def
test_fail_data_without_file
(
self
):
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
self
.
item_location
})
resp
=
self
.
client
.
post
(
link
,
{
'
locator'
:
self
.
item_locator
})
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
'POST data without "file" form data.'
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
'POST data without "file" form data.'
)
def
test_fail_data_with_bad_locat
ion
(
self
):
def
test_fail_data_with_bad_locat
or
(
self
):
# Test for raising `InvalidLocationError` exception.
# Test for raising `InvalidLocationError` exception.
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
resp
=
self
.
client
.
post
(
link
,
{
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
'BAD_LOCATION
'
,
'
locator'
:
'BAD_LOCATOR
'
,
'file'
:
self
.
good_srt_file
,
'file'
:
self
.
good_srt_file
,
'video_list'
:
json
.
dumps
([{
'video_list'
:
json
.
dumps
([{
'type'
:
'html5'
,
'type'
:
'html5'
,
...
@@ -186,13 +186,13 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -186,13 +186,13 @@ class TestUploadtranscripts(Basetranscripts):
}])
}])
})
})
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
ion
."
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
or
."
)
# Test for raising `ItemNotFoundError` exception.
# Test for raising `ItemNotFoundError` exception.
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
resp
=
self
.
client
.
post
(
link
,
{
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
'{0}_{1}'
.
format
(
self
.
item_location
,
'BAD_LOCATION
'
),
'
locator'
:
'{0}_{1}'
.
format
(
self
.
item_locator
,
'BAD_LOCATOR
'
),
'file'
:
self
.
good_srt_file
,
'file'
:
self
.
good_srt_file
,
'video_list'
:
json
.
dumps
([{
'video_list'
:
json
.
dumps
([{
'type'
:
'html5'
,
'type'
:
'html5'
,
...
@@ -201,7 +201,7 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -201,7 +201,7 @@ class TestUploadtranscripts(Basetranscripts):
}])
}])
})
})
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
ion
."
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
or
."
)
def
test_fail_for_non_video_module
(
self
):
def
test_fail_for_non_video_module
(
self
):
# non_video module: setup
# non_video module: setup
...
@@ -211,7 +211,7 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -211,7 +211,7 @@ class TestUploadtranscripts(Basetranscripts):
'type'
:
'non_video'
'type'
:
'non_video'
}
}
resp
=
self
.
client
.
ajax_post
(
'/xblock'
,
data
)
resp
=
self
.
client
.
ajax_post
(
'/xblock'
,
data
)
item_locat
ion
=
self
.
_get_location
(
resp
)
item_locat
or
,
item_location
=
self
.
_get_locator
(
resp
)
data
=
'<non_video youtube="0.75:JMD_ifUUfsU,1.0:hI10vDNYz4M" />'
data
=
'<non_video youtube="0.75:JMD_ifUUfsU,1.0:hI10vDNYz4M" />'
modulestore
()
.
update_item
(
item_location
,
data
)
modulestore
()
.
update_item
(
item_location
,
data
)
...
@@ -220,7 +220,7 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -220,7 +220,7 @@ class TestUploadtranscripts(Basetranscripts):
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
resp
=
self
.
client
.
post
(
link
,
{
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
item_location
,
'
locator'
:
item_locator
,
'file'
:
self
.
good_srt_file
,
'file'
:
self
.
good_srt_file
,
'video_list'
:
json
.
dumps
([{
'video_list'
:
json
.
dumps
([{
'type'
:
'html5'
,
'type'
:
'html5'
,
...
@@ -238,7 +238,7 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -238,7 +238,7 @@ class TestUploadtranscripts(Basetranscripts):
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
good_srt_file
.
name
))[
0
]
resp
=
self
.
client
.
post
(
link
,
{
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
self
.
item_location
,
'
locator'
:
self
.
item_locator
,
'file'
:
self
.
good_srt_file
,
'file'
:
self
.
good_srt_file
,
'video_list'
:
json
.
dumps
([{
'video_list'
:
json
.
dumps
([{
'type'
:
'html5'
,
'type'
:
'html5'
,
...
@@ -255,7 +255,7 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -255,7 +255,7 @@ class TestUploadtranscripts(Basetranscripts):
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
bad_data_srt_file
.
name
))[
0
]
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
bad_data_srt_file
.
name
))[
0
]
resp
=
self
.
client
.
post
(
link
,
{
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
self
.
item_location
,
'
locator'
:
self
.
item_locator
,
'file'
:
self
.
bad_data_srt_file
,
'file'
:
self
.
bad_data_srt_file
,
'video_list'
:
json
.
dumps
([{
'video_list'
:
json
.
dumps
([{
'type'
:
'html5'
,
'type'
:
'html5'
,
...
@@ -270,7 +270,7 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -270,7 +270,7 @@ class TestUploadtranscripts(Basetranscripts):
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
bad_name_srt_file
.
name
))[
0
]
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
bad_name_srt_file
.
name
))[
0
]
resp
=
self
.
client
.
post
(
link
,
{
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
self
.
item_location
,
'
locator'
:
self
.
item_locator
,
'file'
:
self
.
bad_name_srt_file
,
'file'
:
self
.
bad_name_srt_file
,
'video_list'
:
json
.
dumps
([{
'video_list'
:
json
.
dumps
([{
'type'
:
'html5'
,
'type'
:
'html5'
,
...
@@ -297,7 +297,7 @@ class TestUploadtranscripts(Basetranscripts):
...
@@ -297,7 +297,7 @@ class TestUploadtranscripts(Basetranscripts):
link
=
reverse
(
'upload_transcripts'
)
link
=
reverse
(
'upload_transcripts'
)
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
srt_file
.
name
))[
0
]
filename
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
srt_file
.
name
))[
0
]
resp
=
self
.
client
.
post
(
link
,
{
resp
=
self
.
client
.
post
(
link
,
{
'
id'
:
self
.
item_location
,
'
locator'
:
self
.
item_locator
,
'file'
:
srt_file
,
'file'
:
srt_file
,
'video_list'
:
json
.
dumps
([{
'video_list'
:
json
.
dumps
([{
'type'
:
'html5'
,
'type'
:
'html5'
,
...
@@ -359,7 +359,7 @@ class TestDownloadtranscripts(Basetranscripts):
...
@@ -359,7 +359,7 @@ class TestDownloadtranscripts(Basetranscripts):
self
.
save_subs_to_store
(
subs
,
'JMD_ifUUfsU'
)
self
.
save_subs_to_store
(
subs
,
'JMD_ifUUfsU'
)
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id'
:
self
.
item_location
,
'subs_id'
:
"JMD_ifUUfsU"
})
resp
=
self
.
client
.
get
(
link
,
{
'
locator'
:
self
.
item_locator
,
'subs_id'
:
"JMD_ifUUfsU"
})
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
content
,
"""0
\n
00:00:00,100 --> 00:00:00,200
\n
subs #1
\n\n
1
\n
00:00:00,200 --> 00:00:00,240
\n
subs #2
\n\n
2
\n
00:00:00,240 --> 00:00:00,380
\n
subs #3
\n\n
"""
)
self
.
assertEqual
(
resp
.
content
,
"""0
\n
00:00:00,100 --> 00:00:00,200
\n
subs #1
\n\n
1
\n
00:00:00,200 --> 00:00:00,240
\n
subs #2
\n\n
2
\n
00:00:00,240 --> 00:00:00,380
\n
subs #3
\n\n
"""
)
...
@@ -386,7 +386,7 @@ class TestDownloadtranscripts(Basetranscripts):
...
@@ -386,7 +386,7 @@ class TestDownloadtranscripts(Basetranscripts):
self
.
save_subs_to_store
(
subs
,
subs_id
)
self
.
save_subs_to_store
(
subs
,
subs_id
)
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id'
:
self
.
item_location
,
'subs_id'
:
subs_id
})
resp
=
self
.
client
.
get
(
link
,
{
'
locator'
:
self
.
item_locator
,
'subs_id'
:
subs_id
})
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
self
.
assertEqual
(
resp
.
content
,
resp
.
content
,
...
@@ -397,21 +397,21 @@ class TestDownloadtranscripts(Basetranscripts):
...
@@ -397,21 +397,21 @@ class TestDownloadtranscripts(Basetranscripts):
def
test_fail_data_without_file
(
self
):
def
test_fail_data_without_file
(
self
):
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id
'
:
''
})
resp
=
self
.
client
.
get
(
link
,
{
'
locator
'
:
''
})
self
.
assertEqual
(
resp
.
status_code
,
404
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
resp
=
self
.
client
.
get
(
link
,
{})
resp
=
self
.
client
.
get
(
link
,
{})
self
.
assertEqual
(
resp
.
status_code
,
404
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
def
test_fail_data_with_bad_locat
ion
(
self
):
def
test_fail_data_with_bad_locat
or
(
self
):
# Test for raising `InvalidLocationError` exception.
# Test for raising `InvalidLocationError` exception.
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id'
:
'BAD_LOCATION
'
})
resp
=
self
.
client
.
get
(
link
,
{
'
locator'
:
'BAD_LOCATOR
'
})
self
.
assertEqual
(
resp
.
status_code
,
404
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
# Test for raising `ItemNotFoundError` exception.
# Test for raising `ItemNotFoundError` exception.
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id'
:
'{0}_{1}'
.
format
(
self
.
item_location
,
'BAD_LOCATION
'
)})
resp
=
self
.
client
.
get
(
link
,
{
'
locator'
:
'{0}_{1}'
.
format
(
self
.
item_locator
,
'BAD_LOCATOR
'
)})
self
.
assertEqual
(
resp
.
status_code
,
404
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
def
test_fail_for_non_video_module
(
self
):
def
test_fail_for_non_video_module
(
self
):
...
@@ -422,7 +422,7 @@ class TestDownloadtranscripts(Basetranscripts):
...
@@ -422,7 +422,7 @@ class TestDownloadtranscripts(Basetranscripts):
'type'
:
'videoalpha'
'type'
:
'videoalpha'
}
}
resp
=
self
.
client
.
ajax_post
(
'/xblock'
,
data
)
resp
=
self
.
client
.
ajax_post
(
'/xblock'
,
data
)
item_locat
ion
=
self
.
_get_location
(
resp
)
item_locat
or
,
item_location
=
self
.
_get_locator
(
resp
)
subs_id
=
str
(
uuid4
())
subs_id
=
str
(
uuid4
())
data
=
textwrap
.
dedent
(
"""
data
=
textwrap
.
dedent
(
"""
<videoalpha youtube="" sub="{}">
<videoalpha youtube="" sub="{}">
...
@@ -445,7 +445,7 @@ class TestDownloadtranscripts(Basetranscripts):
...
@@ -445,7 +445,7 @@ class TestDownloadtranscripts(Basetranscripts):
self
.
save_subs_to_store
(
subs
,
subs_id
)
self
.
save_subs_to_store
(
subs
,
subs_id
)
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id'
:
item_location
})
resp
=
self
.
client
.
get
(
link
,
{
'
locator'
:
item_locator
})
self
.
assertEqual
(
resp
.
status_code
,
404
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
def
test_fail_nonyoutube_subs_dont_exist
(
self
):
def
test_fail_nonyoutube_subs_dont_exist
(
self
):
...
@@ -459,7 +459,7 @@ class TestDownloadtranscripts(Basetranscripts):
...
@@ -459,7 +459,7 @@ class TestDownloadtranscripts(Basetranscripts):
modulestore
()
.
update_item
(
self
.
item_location
,
data
)
modulestore
()
.
update_item
(
self
.
item_location
,
data
)
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id'
:
self
.
item_location
})
resp
=
self
.
client
.
get
(
link
,
{
'
locator'
:
self
.
item_locator
})
self
.
assertEqual
(
resp
.
status_code
,
404
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
def
test_empty_youtube_attr_and_sub_attr
(
self
):
def
test_empty_youtube_attr_and_sub_attr
(
self
):
...
@@ -473,7 +473,7 @@ class TestDownloadtranscripts(Basetranscripts):
...
@@ -473,7 +473,7 @@ class TestDownloadtranscripts(Basetranscripts):
modulestore
()
.
update_item
(
self
.
item_location
,
data
)
modulestore
()
.
update_item
(
self
.
item_location
,
data
)
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id'
:
self
.
item_location
})
resp
=
self
.
client
.
get
(
link
,
{
'
locator'
:
self
.
item_locator
})
self
.
assertEqual
(
resp
.
status_code
,
404
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
...
@@ -498,7 +498,7 @@ class TestDownloadtranscripts(Basetranscripts):
...
@@ -498,7 +498,7 @@ class TestDownloadtranscripts(Basetranscripts):
self
.
save_subs_to_store
(
subs
,
'JMD_ifUUfsU'
)
self
.
save_subs_to_store
(
subs
,
'JMD_ifUUfsU'
)
link
=
reverse
(
'download_transcripts'
)
link
=
reverse
(
'download_transcripts'
)
resp
=
self
.
client
.
get
(
link
,
{
'
id'
:
self
.
item_location
})
resp
=
self
.
client
.
get
(
link
,
{
'
locator'
:
self
.
item_locator
})
self
.
assertEqual
(
resp
.
status_code
,
404
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
...
@@ -553,7 +553,7 @@ class TestChecktranscripts(Basetranscripts):
...
@@ -553,7 +553,7 @@ class TestChecktranscripts(Basetranscripts):
self
.
save_subs_to_store
(
subs
,
subs_id
)
self
.
save_subs_to_store
(
subs
,
subs_id
)
data
=
{
data
=
{
'
id'
:
self
.
item_location
,
'
locator'
:
self
.
item_locator
,
'videos'
:
[{
'videos'
:
[{
'type'
:
'html5'
,
'type'
:
'html5'
,
'video'
:
subs_id
,
'video'
:
subs_id
,
...
@@ -597,7 +597,7 @@ class TestChecktranscripts(Basetranscripts):
...
@@ -597,7 +597,7 @@ class TestChecktranscripts(Basetranscripts):
self
.
save_subs_to_store
(
subs
,
'JMD_ifUUfsU'
)
self
.
save_subs_to_store
(
subs
,
'JMD_ifUUfsU'
)
link
=
reverse
(
'check_transcripts'
)
link
=
reverse
(
'check_transcripts'
)
data
=
{
data
=
{
'
id'
:
self
.
item_location
,
'
locator'
:
self
.
item_locator
,
'videos'
:
[{
'videos'
:
[{
'type'
:
'youtube'
,
'type'
:
'youtube'
,
'video'
:
'JMD_ifUUfsU'
,
'video'
:
'JMD_ifUUfsU'
,
...
@@ -625,7 +625,7 @@ class TestChecktranscripts(Basetranscripts):
...
@@ -625,7 +625,7 @@ class TestChecktranscripts(Basetranscripts):
def
test_fail_data_without_id
(
self
):
def
test_fail_data_without_id
(
self
):
link
=
reverse
(
'check_transcripts'
)
link
=
reverse
(
'check_transcripts'
)
data
=
{
data
=
{
'
id
'
:
''
,
'
locator
'
:
''
,
'videos'
:
[{
'videos'
:
[{
'type'
:
''
,
'type'
:
''
,
'video'
:
''
,
'video'
:
''
,
...
@@ -634,13 +634,13 @@ class TestChecktranscripts(Basetranscripts):
...
@@ -634,13 +634,13 @@ class TestChecktranscripts(Basetranscripts):
}
}
resp
=
self
.
client
.
get
(
link
,
{
'data'
:
json
.
dumps
(
data
)})
resp
=
self
.
client
.
get
(
link
,
{
'data'
:
json
.
dumps
(
data
)})
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
ion
."
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
or
."
)
def
test_fail_data_with_bad_locat
ion
(
self
):
def
test_fail_data_with_bad_locat
or
(
self
):
# Test for raising `InvalidLocationError` exception.
# Test for raising `InvalidLocationError` exception.
link
=
reverse
(
'check_transcripts'
)
link
=
reverse
(
'check_transcripts'
)
data
=
{
data
=
{
'
id
'
:
''
,
'
locator
'
:
''
,
'videos'
:
[{
'videos'
:
[{
'type'
:
''
,
'type'
:
''
,
'video'
:
''
,
'video'
:
''
,
...
@@ -649,11 +649,11 @@ class TestChecktranscripts(Basetranscripts):
...
@@ -649,11 +649,11 @@ class TestChecktranscripts(Basetranscripts):
}
}
resp
=
self
.
client
.
get
(
link
,
{
'data'
:
json
.
dumps
(
data
)})
resp
=
self
.
client
.
get
(
link
,
{
'data'
:
json
.
dumps
(
data
)})
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
ion
."
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
or
."
)
# Test for raising `ItemNotFoundError` exception.
# Test for raising `ItemNotFoundError` exception.
data
=
{
data
=
{
'
id'
:
'{0}_{1}'
.
format
(
self
.
item_location
,
'BAD_LOCATION
'
),
'
locator'
:
'{0}_{1}'
.
format
(
self
.
item_locator
,
'BAD_LOCATOR
'
),
'videos'
:
[{
'videos'
:
[{
'type'
:
''
,
'type'
:
''
,
'video'
:
''
,
'video'
:
''
,
...
@@ -662,7 +662,7 @@ class TestChecktranscripts(Basetranscripts):
...
@@ -662,7 +662,7 @@ class TestChecktranscripts(Basetranscripts):
}
}
resp
=
self
.
client
.
get
(
link
,
{
'data'
:
json
.
dumps
(
data
)})
resp
=
self
.
client
.
get
(
link
,
{
'data'
:
json
.
dumps
(
data
)})
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
ion
."
)
self
.
assertEqual
(
json
.
loads
(
resp
.
content
)
.
get
(
'status'
),
"Can't find item by locat
or
."
)
def
test_fail_for_non_video_module
(
self
):
def
test_fail_for_non_video_module
(
self
):
# Not video module: setup
# Not video module: setup
...
@@ -672,7 +672,7 @@ class TestChecktranscripts(Basetranscripts):
...
@@ -672,7 +672,7 @@ class TestChecktranscripts(Basetranscripts):
'type'
:
'not_video'
'type'
:
'not_video'
}
}
resp
=
self
.
client
.
ajax_post
(
'/xblock'
,
data
)
resp
=
self
.
client
.
ajax_post
(
'/xblock'
,
data
)
item_locat
ion
=
self
.
_get_location
(
resp
)
item_locat
or
,
item_location
=
self
.
_get_locator
(
resp
)
subs_id
=
str
(
uuid4
())
subs_id
=
str
(
uuid4
())
data
=
textwrap
.
dedent
(
"""
data
=
textwrap
.
dedent
(
"""
<not_video youtube="" sub="{}">
<not_video youtube="" sub="{}">
...
@@ -695,7 +695,7 @@ class TestChecktranscripts(Basetranscripts):
...
@@ -695,7 +695,7 @@ class TestChecktranscripts(Basetranscripts):
self
.
save_subs_to_store
(
subs
,
subs_id
)
self
.
save_subs_to_store
(
subs
,
subs_id
)
data
=
{
data
=
{
'
id'
:
item_location
,
'
locator'
:
item_locator
,
'videos'
:
[{
'videos'
:
[{
'type'
:
''
,
'type'
:
''
,
'video'
:
''
,
'video'
:
''
,
...
...
cms/djangoapps/contentstore/views/component.py
View file @
2682a14d
...
@@ -223,13 +223,9 @@ def unit_handler(request, tag=None, course_id=None, branch=None, version_guid=No
...
@@ -223,13 +223,9 @@ def unit_handler(request, tag=None, course_id=None, branch=None, version_guid=No
)
)
components
=
[
components
=
[
[
loc_mapper
()
.
translate_location
(
# TODO: old location needed for video transcripts.
course
.
location
.
course_id
,
component
.
location
,
False
,
True
component
.
location
.
url
(),
)
loc_mapper
()
.
translate_location
(
course
.
location
.
course_id
,
component
.
location
,
False
,
True
)
]
for
component
for
component
in
item
.
get_children
()
in
item
.
get_children
()
]
]
...
...
cms/djangoapps/contentstore/views/transcripts_ajax.py
View file @
2682a14d
...
@@ -18,11 +18,12 @@ from django.conf import settings
...
@@ -18,11 +18,12 @@ from django.conf import settings
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.exceptions
import
NotFoundError
from
xmodule.exceptions
import
NotFoundError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
,
loc_mapper
from
xmodule.contentstore.django
import
contentstore
from
xmodule.contentstore.django
import
contentstore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
InvalidLocationError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
InvalidLocationError
,
InsufficientSpecificationError
from
util.json_request
import
JsonResponse
from
util.json_request
import
JsonResponse
from
xmodule.modulestore.locator
import
BlockUsageLocator
from
..transcripts_utils
import
(
from
..transcripts_utils
import
(
generate_subs_from_source
,
generate_subs_from_source
,
...
@@ -77,20 +78,14 @@ def upload_transcripts(request):
...
@@ -77,20 +78,14 @@ def upload_transcripts(request):
'subs'
:
''
,
'subs'
:
''
,
}
}
item_location
=
request
.
POST
.
get
(
'id
'
)
locator
=
request
.
POST
.
get
(
'locator
'
)
if
not
item_location
:
if
not
locator
:
return
error_response
(
response
,
'POST data without "
id
" form data.'
)
return
error_response
(
response
,
'POST data without "
locator
" form data.'
)
# This is placed before has_access() to validate item_location,
# because has_access() raises InvalidLocationError if location is invalid.
try
:
try
:
item
=
modulestore
()
.
get_item
(
item_location
)
item
=
_get_item
(
request
,
request
.
POST
)
except
(
ItemNotFoundError
,
InvalidLocationError
):
except
(
ItemNotFoundError
,
InvalidLocationError
,
InsufficientSpecificationError
):
return
error_response
(
response
,
"Can't find item by location."
)
return
error_response
(
response
,
"Can't find item by locator."
)
# Check permissions for this user within this course.
if
not
has_access
(
request
.
user
,
item_location
):
raise
PermissionDenied
()
if
'file'
not
in
request
.
FILES
:
if
'file'
not
in
request
.
FILES
:
return
error_response
(
response
,
'POST data without "file" form data.'
)
return
error_response
(
response
,
'POST data without "file" form data.'
)
...
@@ -156,23 +151,17 @@ def download_transcripts(request):
...
@@ -156,23 +151,17 @@ def download_transcripts(request):
Raises Http404 if unsuccessful.
Raises Http404 if unsuccessful.
"""
"""
item_location
=
request
.
GET
.
get
(
'id
'
)
locator
=
request
.
GET
.
get
(
'locator
'
)
if
not
item_location
:
if
not
locator
:
log
.
debug
(
'GET data without "
id
" property.'
)
log
.
debug
(
'GET data without "
locator
" property.'
)
raise
Http404
raise
Http404
# This is placed before has_access() to validate item_location,
# because has_access() raises InvalidLocationError if location is invalid.
try
:
try
:
item
=
modulestore
()
.
get_item
(
item_location
)
item
=
_get_item
(
request
,
request
.
GET
)
except
(
ItemNotFoundError
,
InvalidLocationError
):
except
(
ItemNotFoundError
,
InvalidLocationError
,
InsufficientSpecificationError
):
log
.
debug
(
"Can't find item by locat
ion
."
)
log
.
debug
(
"Can't find item by locat
or
."
)
raise
Http404
raise
Http404
# Check permissions for this user within this course.
if
not
has_access
(
request
.
user
,
item_location
):
raise
PermissionDenied
()
subs_id
=
request
.
GET
.
get
(
'subs_id'
)
subs_id
=
request
.
GET
.
get
(
'subs_id'
)
if
not
subs_id
:
if
not
subs_id
:
log
.
debug
(
'GET data without "subs_id" property.'
)
log
.
debug
(
'GET data without "subs_id" property.'
)
...
@@ -240,7 +229,7 @@ def check_transcripts(request):
...
@@ -240,7 +229,7 @@ def check_transcripts(request):
'status'
:
'Error'
,
'status'
:
'Error'
,
}
}
try
:
try
:
__
,
videos
,
item
=
validate_transcripts_data
(
request
)
__
,
videos
,
item
=
_
validate_transcripts_data
(
request
)
except
TranscriptsRequestValidationException
as
e
:
except
TranscriptsRequestValidationException
as
e
:
return
error_response
(
transcripts_presence
,
e
.
message
)
return
error_response
(
transcripts_presence
,
e
.
message
)
...
@@ -303,7 +292,7 @@ def check_transcripts(request):
...
@@ -303,7 +292,7 @@ def check_transcripts(request):
if
len
(
html5_subs
)
==
2
:
# check html5 transcripts for equality
if
len
(
html5_subs
)
==
2
:
# check html5 transcripts for equality
transcripts_presence
[
'html5_equal'
]
=
json
.
loads
(
html5_subs
[
0
])
==
json
.
loads
(
html5_subs
[
1
])
transcripts_presence
[
'html5_equal'
]
=
json
.
loads
(
html5_subs
[
0
])
==
json
.
loads
(
html5_subs
[
1
])
command
,
subs_to_use
=
transcripts_logic
(
transcripts_presence
,
videos
)
command
,
subs_to_use
=
_
transcripts_logic
(
transcripts_presence
,
videos
)
transcripts_presence
.
update
({
transcripts_presence
.
update
({
'command'
:
command
,
'command'
:
command
,
'subs'
:
subs_to_use
,
'subs'
:
subs_to_use
,
...
@@ -311,7 +300,7 @@ def check_transcripts(request):
...
@@ -311,7 +300,7 @@ def check_transcripts(request):
return
JsonResponse
(
transcripts_presence
)
return
JsonResponse
(
transcripts_presence
)
def
transcripts_logic
(
transcripts_presence
,
videos
):
def
_
transcripts_logic
(
transcripts_presence
,
videos
):
"""
"""
By `transcripts_presence` content, figure what show to user:
By `transcripts_presence` content, figure what show to user:
...
@@ -386,7 +375,7 @@ def choose_transcripts(request):
...
@@ -386,7 +375,7 @@ def choose_transcripts(request):
}
}
try
:
try
:
data
,
videos
,
item
=
validate_transcripts_data
(
request
)
data
,
videos
,
item
=
_
validate_transcripts_data
(
request
)
except
TranscriptsRequestValidationException
as
e
:
except
TranscriptsRequestValidationException
as
e
:
return
error_response
(
response
,
e
.
message
)
return
error_response
(
response
,
e
.
message
)
...
@@ -416,7 +405,7 @@ def replace_transcripts(request):
...
@@ -416,7 +405,7 @@ def replace_transcripts(request):
response
=
{
'status'
:
'Error'
,
'subs'
:
''
}
response
=
{
'status'
:
'Error'
,
'subs'
:
''
}
try
:
try
:
__
,
videos
,
item
=
validate_transcripts_data
(
request
)
__
,
videos
,
item
=
_
validate_transcripts_data
(
request
)
except
TranscriptsRequestValidationException
as
e
:
except
TranscriptsRequestValidationException
as
e
:
return
error_response
(
response
,
e
.
message
)
return
error_response
(
response
,
e
.
message
)
...
@@ -435,7 +424,7 @@ def replace_transcripts(request):
...
@@ -435,7 +424,7 @@ def replace_transcripts(request):
return
JsonResponse
(
response
)
return
JsonResponse
(
response
)
def
validate_transcripts_data
(
request
):
def
_
validate_transcripts_data
(
request
):
"""
"""
Validates, that request contains all proper data for transcripts processing.
Validates, that request contains all proper data for transcripts processing.
...
@@ -452,18 +441,10 @@ def validate_transcripts_data(request):
...
@@ -452,18 +441,10 @@ def validate_transcripts_data(request):
if
not
data
:
if
not
data
:
raise
TranscriptsRequestValidationException
(
'Incoming video data is empty.'
)
raise
TranscriptsRequestValidationException
(
'Incoming video data is empty.'
)
item_location
=
data
.
get
(
'id'
)
# This is placed before has_access() to validate item_location,
# because has_access() raises InvalidLocationError if location is invalid.
try
:
try
:
item
=
modulestore
()
.
get_item
(
item_location
)
item
=
_get_item
(
request
,
data
)
except
(
ItemNotFoundError
,
InvalidLocationError
):
except
(
ItemNotFoundError
,
InvalidLocationError
,
InsufficientSpecificationError
):
raise
TranscriptsRequestValidationException
(
"Can't find item by location."
)
raise
TranscriptsRequestValidationException
(
"Can't find item by locator."
)
# Check permissions for this user within this course.
if
not
has_access
(
request
.
user
,
item_location
):
raise
PermissionDenied
()
if
item
.
category
!=
'video'
:
if
item
.
category
!=
'video'
:
raise
TranscriptsRequestValidationException
(
'Transcripts are supported only for "video" modules.'
)
raise
TranscriptsRequestValidationException
(
'Transcripts are supported only for "video" modules.'
)
...
@@ -492,7 +473,7 @@ def rename_transcripts(request):
...
@@ -492,7 +473,7 @@ def rename_transcripts(request):
response
=
{
'status'
:
'Error'
,
'subs'
:
''
}
response
=
{
'status'
:
'Error'
,
'subs'
:
''
}
try
:
try
:
__
,
videos
,
item
=
validate_transcripts_data
(
request
)
__
,
videos
,
item
=
_
validate_transcripts_data
(
request
)
except
TranscriptsRequestValidationException
as
e
:
except
TranscriptsRequestValidationException
as
e
:
return
error_response
(
response
,
e
.
message
)
return
error_response
(
response
,
e
.
message
)
...
@@ -525,11 +506,10 @@ def save_transcripts(request):
...
@@ -525,11 +506,10 @@ def save_transcripts(request):
if
not
data
:
if
not
data
:
return
error_response
(
response
,
'Incoming video data is empty.'
)
return
error_response
(
response
,
'Incoming video data is empty.'
)
item_location
=
data
.
get
(
'id'
)
try
:
try
:
item
=
modulestore
()
.
get_item
(
item_location
)
item
=
_get_item
(
request
,
data
)
except
(
ItemNotFoundError
,
InvalidLocationError
):
except
(
ItemNotFoundError
,
InvalidLocationError
,
InsufficientSpecificationError
):
return
error_response
(
response
,
"Can't find item by locat
ion
."
)
return
error_response
(
response
,
"Can't find item by locat
or
."
)
metadata
=
data
.
get
(
'metadata'
)
metadata
=
data
.
get
(
'metadata'
)
if
metadata
is
not
None
:
if
metadata
is
not
None
:
...
@@ -553,3 +533,24 @@ def save_transcripts(request):
...
@@ -553,3 +533,24 @@ def save_transcripts(request):
response
[
'status'
]
=
'Success'
response
[
'status'
]
=
'Success'
return
JsonResponse
(
response
)
return
JsonResponse
(
response
)
def
_get_item
(
request
,
data
):
"""
Obtains from 'data' the locator for an item.
Next, gets that item from the modulestore (allowing any errors to raise up).
Finally, verifies that the user has access to the item.
Returns the item.
"""
locator
=
BlockUsageLocator
(
data
.
get
(
'locator'
))
old_location
=
loc_mapper
()
.
translate_locator_to_location
(
locator
)
# This is placed before has_access() to validate the location,
# because has_access() raises InvalidLocationError if location is invalid.
item
=
modulestore
()
.
get_item
(
old_location
)
if
not
has_access
(
request
.
user
,
locator
):
raise
PermissionDenied
()
return
item
cms/static/js/spec/transcripts/file_uploader_spec.js
View file @
2682a14d
...
@@ -48,7 +48,7 @@ function ($, _, Utils, FileUploader) {
...
@@ -48,7 +48,7 @@ function ($, _, Utils, FileUploader) {
el
:
$container
,
el
:
$container
,
messenger
:
messenger
,
messenger
:
messenger
,
videoListObject
:
videoListObject
,
videoListObject
:
videoListObject
,
component_
id
:
'component_id
'
component_
locator
:
'component_locator
'
});
});
});
});
...
...
cms/static/js/spec/transcripts/message_manager_spec.js
View file @
2682a14d
...
@@ -52,7 +52,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
...
@@ -52,7 +52,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
view
=
new
MessageManager
({
view
=
new
MessageManager
({
el
:
$container
,
el
:
$container
,
parent
:
videoList
,
parent
:
videoList
,
component_
id
:
'component_id
'
component_
locator
:
'component_locator
'
});
});
});
});
...
@@ -60,7 +60,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
...
@@ -60,7 +60,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
expect
(
fileUploader
.
initialize
).
toHaveBeenCalledWith
({
expect
(
fileUploader
.
initialize
).
toHaveBeenCalledWith
({
el
:
view
.
$el
,
el
:
view
.
$el
,
messenger
:
view
,
messenger
:
view
,
component_
id
:
view
.
component_id
,
component_
locator
:
view
.
component_locator
,
videoListObject
:
view
.
options
.
parent
videoListObject
:
view
.
options
.
parent
});
});
});
});
...
@@ -215,7 +215,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
...
@@ -215,7 +215,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
function
()
{
function
()
{
expect
(
Utils
.
command
).
toHaveBeenCalledWith
(
expect
(
Utils
.
command
).
toHaveBeenCalledWith
(
action
,
action
,
view
.
component_
id
,
view
.
component_
locator
,
videoList
,
videoList
,
void
(
0
)
void
(
0
)
);
);
...
@@ -245,7 +245,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
...
@@ -245,7 +245,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
function
()
{
function
()
{
expect
(
Utils
.
command
).
toHaveBeenCalledWith
(
expect
(
Utils
.
command
).
toHaveBeenCalledWith
(
action
,
action
,
view
.
component_
id
,
view
.
component_
locator
,
videoList
,
videoList
,
{
{
html5_id
:
extraParamas
html5_id
:
extraParamas
...
@@ -268,7 +268,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
...
@@ -268,7 +268,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
function
()
{
function
()
{
expect
(
Utils
.
command
).
toHaveBeenCalledWith
(
expect
(
Utils
.
command
).
toHaveBeenCalledWith
(
action
,
action
,
view
.
component_
id
,
view
.
component_
locator
,
videoList
,
videoList
,
void
(
0
)
void
(
0
)
);
);
...
...
cms/static/js/spec/transcripts/videolist_spec.js
View file @
2682a14d
...
@@ -11,7 +11,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
...
@@ -11,7 +11,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
'transcripts/metadata-videolist-entry.underscore'
'transcripts/metadata-videolist-entry.underscore'
),
),
abstractEditor
=
AbstractEditor
.
prototype
,
abstractEditor
=
AbstractEditor
.
prototype
,
component_
id
=
'component_id
'
,
component_
locator
=
'component_locator
'
,
videoList
=
[
videoList
=
[
{
{
mode
:
"youtube"
,
mode
:
"youtube"
,
...
@@ -62,7 +62,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
...
@@ -62,7 +62,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
var
tpl
=
sandbox
({
var
tpl
=
sandbox
({
'class'
:
'component'
,
'class'
:
'component'
,
'data-
id'
:
component_id
'data-
locator'
:
component_locator
}),
}),
model
=
new
MetadataModel
(
modelStub
),
model
=
new
MetadataModel
(
modelStub
),
videoList
,
$el
;
videoList
,
$el
;
...
@@ -157,7 +157,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
...
@@ -157,7 +157,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
waitsForResponse
(
function
()
{
waitsForResponse
(
function
()
{
expect
(
abstractEditor
.
initialize
).
toHaveBeenCalled
();
expect
(
abstractEditor
.
initialize
).
toHaveBeenCalled
();
expect
(
messenger
.
initialize
).
toHaveBeenCalled
();
expect
(
messenger
.
initialize
).
toHaveBeenCalled
();
expect
(
view
.
component_
id
).
toBe
(
component_id
);
expect
(
view
.
component_
locator
).
toBe
(
component_locator
);
expect
(
view
.
$el
).
toHandle
(
'input'
);
expect
(
view
.
$el
).
toHandle
(
'input'
);
});
});
});
});
...
@@ -167,7 +167,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
...
@@ -167,7 +167,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
expect
(
abstractEditor
.
render
).
toHaveBeenCalled
();
expect
(
abstractEditor
.
render
).
toHaveBeenCalled
();
expect
(
Utils
.
command
).
toHaveBeenCalledWith
(
expect
(
Utils
.
command
).
toHaveBeenCalledWith
(
'check'
,
'check'
,
component_
id
,
component_
locator
,
videoList
videoList
);
);
...
...
cms/static/js/views/transcripts/editor.js
View file @
2682a14d
...
@@ -72,7 +72,7 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
...
@@ -72,7 +72,7 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
syncBasicTab
:
function
(
metadataCollection
,
metadataView
)
{
syncBasicTab
:
function
(
metadataCollection
,
metadataView
)
{
var
result
=
[],
var
result
=
[],
getField
=
Utils
.
getField
,
getField
=
Utils
.
getField
,
component_
id
=
this
.
$el
.
closest
(
'.component'
).
data
(
'id
'
),
component_
locator
=
this
.
$el
.
closest
(
'.component'
).
data
(
'locator
'
),
subs
=
getField
(
metadataCollection
,
'sub'
),
subs
=
getField
(
metadataCollection
,
'sub'
),
values
=
{},
values
=
{},
videoUrl
,
metadata
,
modifiedValues
;
videoUrl
,
metadata
,
modifiedValues
;
...
@@ -99,7 +99,7 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
...
@@ -99,7 +99,7 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
if
(
isSubsModified
)
{
if
(
isSubsModified
)
{
metadata
=
$
.
extend
(
true
,
{},
modifiedValues
);
metadata
=
$
.
extend
(
true
,
{},
modifiedValues
);
// Save module state
// Save module state
Utils
.
command
(
'save'
,
component_
id
,
null
,
{
Utils
.
command
(
'save'
,
component_
locator
,
null
,
{
metadata
:
metadata
,
metadata
:
metadata
,
current_subs
:
_
.
pluck
(
current_subs
:
_
.
pluck
(
Utils
.
getVideoList
(
videoUrl
.
getDisplayValue
()),
Utils
.
getVideoList
(
videoUrl
.
getDisplayValue
()),
...
@@ -110,18 +110,16 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
...
@@ -110,18 +110,16 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
// Get values from `Advanced` tab fields (`html5_sources`,
// Get values from `Advanced` tab fields (`html5_sources`,
// `youtube_id_1_0`) that should be synchronized.
// `youtube_id_1_0`) that should be synchronized.
html5Sources
=
getField
(
metadataCollection
,
'html5_sources'
)
var
html5Sources
=
getField
(
metadataCollection
,
'html5_sources'
).
getDisplayValue
();
.
getDisplayValue
();
values
.
youtube
=
getField
(
metadataCollection
,
'youtube_id_1_0'
)
values
.
youtube
=
getField
(
metadataCollection
,
'youtube_id_1_0'
).
getDisplayValue
();
.
getDisplayValue
();
values
.
html5Sources
=
_
.
filter
(
html5Sources
,
function
(
value
)
{
values
.
html5Sources
=
_
.
filter
(
html5Sources
,
function
(
value
)
{
var
link
=
Utils
.
parseLink
(
value
),
var
link
=
Utils
.
parseLink
(
value
),
mode
=
link
&&
link
.
mode
;
mode
=
link
&&
link
.
mode
;
return
mode
===
'html5'
&&
mode
;
return
mode
===
'html5'
&&
mode
;
});
});
// The length of youtube video_id should be 11 characters.
// The length of youtube video_id should be 11 characters.
...
...
cms/static/js/views/transcripts/file_uploader.js
View file @
2682a14d
...
@@ -39,7 +39,7 @@ function($, Backbone, _, Utils) {
...
@@ -39,7 +39,7 @@ function($, Backbone, _, Utils) {
tplContainer
.
html
(
this
.
template
({
tplContainer
.
html
(
this
.
template
({
ext
:
this
.
validFileExtensions
,
ext
:
this
.
validFileExtensions
,
component_
id
:
this
.
options
.
component_id
,
component_
locator
:
this
.
options
.
component_locator
,
video_list
:
videoList
video_list
:
videoList
}));
}));
...
...
cms/static/js/views/transcripts/message_manager.js
View file @
2682a14d
...
@@ -31,12 +31,12 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
...
@@ -31,12 +31,12 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
initialize
:
function
()
{
initialize
:
function
()
{
_
.
bindAll
(
this
);
_
.
bindAll
(
this
);
this
.
component_
id
=
this
.
$el
.
closest
(
'.component'
).
data
(
'id
'
);
this
.
component_
locator
=
this
.
$el
.
closest
(
'.component'
).
data
(
'locator
'
);
this
.
fileUploader
=
new
FileUploader
({
this
.
fileUploader
=
new
FileUploader
({
el
:
this
.
$el
,
el
:
this
.
$el
,
messenger
:
this
,
messenger
:
this
,
component_
id
:
this
.
component_id
,
component_
locator
:
this
.
component_locator
,
videoListObject
:
this
.
options
.
parent
videoListObject
:
this
.
options
.
parent
});
});
},
},
...
@@ -76,7 +76,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
...
@@ -76,7 +76,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
this
.
$el
.
find
(
'.transcripts-status'
)
this
.
$el
.
find
(
'.transcripts-status'
)
.
removeClass
(
'is-invisible'
)
.
removeClass
(
'is-invisible'
)
.
find
(
this
.
elClass
).
html
(
template
({
.
find
(
this
.
elClass
).
html
(
template
({
component_
id
:
encodeURIComponent
(
this
.
component_id
),
component_
locator
:
encodeURIComponent
(
this
.
component_locator
),
html5_list
:
html5List
,
html5_list
:
html5List
,
grouped_list
:
groupedList
,
grouped_list
:
groupedList
,
subs_id
:
(
params
)
?
params
.
subs
:
''
subs_id
:
(
params
)
?
params
.
subs
:
''
...
@@ -204,7 +204,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
...
@@ -204,7 +204,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
*/
*/
processCommand
:
function
(
action
,
errorMessage
,
videoId
)
{
processCommand
:
function
(
action
,
errorMessage
,
videoId
)
{
var
self
=
this
,
var
self
=
this
,
component_
id
=
this
.
component_id
,
component_
locator
=
this
.
component_locator
,
videoList
=
this
.
options
.
parent
.
getVideoObjectsList
(),
videoList
=
this
.
options
.
parent
.
getVideoObjectsList
(),
extraParam
,
xhr
;
extraParam
,
xhr
;
...
@@ -212,7 +212,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
...
@@ -212,7 +212,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
extraParam
=
{
html5_id
:
videoId
};
extraParam
=
{
html5_id
:
videoId
};
}
}
xhr
=
Utils
.
command
(
action
,
component_
id
,
videoList
,
extraParam
)
xhr
=
Utils
.
command
(
action
,
component_
locator
,
videoList
,
extraParam
)
.
done
(
function
(
resp
)
{
.
done
(
function
(
resp
)
{
var
sub
=
resp
.
subs
;
var
sub
=
resp
.
subs
;
...
...
cms/static/js/views/transcripts/metadata_videolist.js
View file @
2682a14d
...
@@ -46,7 +46,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
...
@@ -46,7 +46,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
_
.
debounce
(
_
.
bind
(
this
.
inputHandler
,
this
),
this
.
inputDelay
)
_
.
debounce
(
_
.
bind
(
this
.
inputHandler
,
this
),
this
.
inputDelay
)
);
);
this
.
component_
id
=
this
.
$el
.
closest
(
'.component'
).
data
(
'id
'
);
this
.
component_
locator
=
this
.
$el
.
closest
(
'.component'
).
data
(
'locator
'
);
},
},
render
:
function
()
{
render
:
function
()
{
...
@@ -55,7 +55,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
...
@@ -55,7 +55,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
.
apply
(
this
,
arguments
);
.
apply
(
this
,
arguments
);
var
self
=
this
,
var
self
=
this
,
component_
id
=
this
.
$el
.
closest
(
'.component'
).
data
(
'id
'
),
component_
locator
=
this
.
$el
.
closest
(
'.component'
).
data
(
'locator
'
),
videoList
=
this
.
getVideoObjectsList
(),
videoList
=
this
.
getVideoObjectsList
(),
showServerError
=
function
(
response
)
{
showServerError
=
function
(
response
)
{
...
@@ -82,7 +82,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
...
@@ -82,7 +82,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
}
}
// Check current state of Timed Transcripts.
// Check current state of Timed Transcripts.
Utils
.
command
(
'check'
,
component_
id
,
videoList
)
Utils
.
command
(
'check'
,
component_
locator
,
videoList
)
.
done
(
function
(
resp
)
{
.
done
(
function
(
resp
)
{
var
params
=
resp
,
var
params
=
resp
,
len
=
videoList
.
length
,
len
=
videoList
.
length
,
...
...
cms/static/js/views/transcripts/utils.js
View file @
2682a14d
...
@@ -295,7 +295,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
...
@@ -295,7 +295,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
*
*
* @param {string} action Action that will be invoked on server. Is a part
* @param {string} action Action that will be invoked on server. Is a part
* of url.
* of url.
* @param {string} component_
id Id
of component.
* @param {string} component_
locator the locator
of component.
* @param {array} videoList List of object with information about inserted
* @param {array} videoList List of object with information about inserted
* urls.
* urls.
* @param {object} extraParams Extra parameters that can be send to the
* @param {object} extraParams Extra parameters that can be send to the
...
@@ -314,7 +314,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
...
@@ -314,7 +314,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
// _command() function.
// _command() function.
var
xhr
=
null
;
var
xhr
=
null
;
return
function
(
action
,
component_
id
,
videoList
,
extraParams
)
{
return
function
(
action
,
component_
locator
,
videoList
,
extraParams
)
{
var
params
,
data
;
var
params
,
data
;
if
(
extraParams
)
{
if
(
extraParams
)
{
...
@@ -326,7 +326,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
...
@@ -326,7 +326,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
}
}
data
=
$
.
extend
(
data
=
$
.
extend
(
{
id
:
component_id
},
{
locator
:
component_locator
},
{
videos
:
videoList
},
{
videos
:
videoList
},
params
params
);
);
...
...
cms/templates/js/transcripts/file-upload.underscore
View file @
2682a14d
...
@@ -5,6 +5,6 @@
...
@@ -5,6 +5,6 @@
method="post" enctype="multipart/form-data">
method="post" enctype="multipart/form-data">
<input type="file" class="file-input" name="file"
<input type="file" class="file-input" name="file"
accept="<%= _.map(ext, function(val){ return '.' + val; }).join(', ') %>">
accept="<%= _.map(ext, function(val){ return '.' + val; }).join(', ') %>">
<input type="hidden" name="
id" value="<%= component_id
%>">
<input type="hidden" name="
locator" value="<%= component_locator
%>">
<input type="hidden" name="video_list" value='<%= JSON.stringify(video_list) %>'>
<input type="hidden" name="video_list" value='<%= JSON.stringify(video_list) %>'>
</form>
</form>
cms/templates/js/transcripts/messages/transcripts-found.underscore
View file @
2682a14d
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<button class="action setting-upload" type="button" name="setting-upload" value="<%= gettext("Upload New Timed Transcript") %>" data-tooltip="<%= gettext("Upload New Timed Transcript") %>">
<button class="action setting-upload" type="button" name="setting-upload" value="<%= gettext("Upload New Timed Transcript") %>" data-tooltip="<%= gettext("Upload New Timed Transcript") %>">
<span><%= gettext("Upload New Timed Transcript") %></span>
<span><%= gettext("Upload New Timed Transcript") %></span>
</button>
</button>
<a class="action setting-download" href="/transcripts/download?
id=<%= component_id
%>&subs_id=<%= subs_id %>" data-tooltip="<%= gettext("Download to Edit") %>">
<a class="action setting-download" href="/transcripts/download?
locator=<%= component_locator
%>&subs_id=<%= subs_id %>" data-tooltip="<%= gettext("Download to Edit") %>">
<span><%= gettext("Download to Edit") %></span>
<span><%= gettext("Download to Edit") %></span>
</a>
</a>
</div>
</div>
cms/templates/js/transcripts/messages/transcripts-uploaded.underscore
View file @
2682a14d
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<button class="action setting-upload" type="button" name="setting-upload" value="<%= gettext("Upload New Timed Transcript") %>" data-tooltip="<%= gettext("Upload New Timed Transcript") %>">
<button class="action setting-upload" type="button" name="setting-upload" value="<%= gettext("Upload New Timed Transcript") %>" data-tooltip="<%= gettext("Upload New Timed Transcript") %>">
<span><%= gettext("Upload New Timed Transcript") %></span>
<span><%= gettext("Upload New Timed Transcript") %></span>
</button>
</button>
<a class="action setting-download" href="/transcripts/download?
id=<%= component_id
%>" data-tooltip="<%= gettext("Download to Edit") %>">
<a class="action setting-download" href="/transcripts/download?
locator=<%= component_locator
%>" data-tooltip="<%= gettext("Download to Edit") %>">
<span><%= gettext("Download to Edit") %></span>
<span><%= gettext("Download to Edit") %></span>
</a>
</a>
</div>
</div>
cms/templates/unit.html
View file @
2682a14d
...
@@ -48,8 +48,8 @@ require(["domReady!", "jquery", "js/models/module_info", "coffee/src/views/unit"
...
@@ -48,8 +48,8 @@ require(["domReady!", "jquery", "js/models/module_info", "coffee/src/views/unit"
<article
class=
"unit-body window"
>
<article
class=
"unit-body window"
>
<p
class=
"unit-name-input"
><label>
${_("Display Name:")}
</label><input
type=
"text"
value=
"${unit.display_name_with_default | h}"
class=
"unit-display-name-input"
/></p>
<p
class=
"unit-name-input"
><label>
${_("Display Name:")}
</label><input
type=
"text"
value=
"${unit.display_name_with_default | h}"
class=
"unit-display-name-input"
/></p>
<ol
class=
"components"
>
<ol
class=
"components"
>
% for
id,
locator in components:
% for locator in components:
<li
class=
"component"
data-locator=
"${locator}"
data-id=
"${id}"
/>
<li
class=
"component"
data-locator=
"${locator}"
/>
% endfor
% endfor
<li
class=
"new-component-item adding"
>
<li
class=
"new-component-item adding"
>
<div
class=
"new-component"
>
<div
class=
"new-component"
>
...
...
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