Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-val
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-val
Commits
ad63a296
Unverified
Commit
ad63a296
authored
Jul 05, 2018
by
M. Rehan
Committed by
GitHub
Jul 05, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #141 from edx/mrehan/fix-external-vid-imports
Fix existing external videos import into a course
parents
74cd7fc3
08affff0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
6 deletions
+38
-6
edxval/admin.py
+1
-0
edxval/api.py
+7
-4
edxval/models.py
+1
-0
edxval/tests/constants.py
+8
-1
edxval/tests/test_api.py
+20
-0
setup.py
+1
-1
No files found.
edxval/admin.py
View file @
ad63a296
...
@@ -57,6 +57,7 @@ class VideoImageAdmin(admin.ModelAdmin):
...
@@ -57,6 +57,7 @@ class VideoImageAdmin(admin.ModelAdmin):
class
CourseVideoAdmin
(
admin
.
ModelAdmin
):
class
CourseVideoAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'course_id'
,
'get_video_id'
,
'is_hidden'
)
list_display
=
(
'course_id'
,
'get_video_id'
,
'is_hidden'
)
search_fields
=
(
'id'
,
'course_id'
,
'video__status'
,
'video__edx_video_id'
)
def
get_video_id
(
self
,
obj
):
def
get_video_id
(
self
,
obj
):
return
obj
.
video
.
edx_video_id
return
obj
.
video
.
edx_video_id
...
...
edxval/api.py
View file @
ad63a296
...
@@ -3,13 +3,11 @@
...
@@ -3,13 +3,11 @@
"""
"""
The internal API for VAL.
The internal API for VAL.
"""
"""
import
os
import
logging
import
logging
from
enum
import
Enum
from
enum
import
Enum
from
uuid
import
uuid4
from
uuid
import
uuid4
from
django.core.exceptions
import
ObjectDoesNotExist
,
ValidationError
from
django.core.exceptions
import
ObjectDoesNotExist
,
ValidationError
from
django.core.files
import
File
from
django.core.files.base
import
ContentFile
from
django.core.files.base
import
ContentFile
from
fs
import
open_fs
from
fs
import
open_fs
from
fs.errors
import
ResourceNotFound
from
fs.errors
import
ResourceNotFound
...
@@ -36,6 +34,7 @@ from edxval.models import (
...
@@ -36,6 +34,7 @@ from edxval.models import (
Video
,
Video
,
VideoImage
,
VideoImage
,
VideoTranscript
,
VideoTranscript
,
EXTERNAL_VIDEO_STATUS
,
ThirdPartyTranscriptCredentialsState
,
ThirdPartyTranscriptCredentialsState
,
)
)
from
edxval.serializers
import
TranscriptPreferenceSerializer
,
TranscriptSerializer
,
VideoSerializer
from
edxval.serializers
import
TranscriptPreferenceSerializer
,
TranscriptSerializer
,
VideoSerializer
...
@@ -122,7 +121,7 @@ def create_external_video(display_name):
...
@@ -122,7 +121,7 @@ def create_external_video(display_name):
"""
"""
return
create_video
({
return
create_video
({
'edx_video_id'
:
generate_video_id
(),
'edx_video_id'
:
generate_video_id
(),
'status'
:
'external'
,
'status'
:
EXTERNAL_VIDEO_STATUS
,
'client_video_id'
:
display_name
,
'client_video_id'
:
display_name
,
'duration'
:
0
,
'duration'
:
0
,
'encoded_videos'
:
[],
'encoded_videos'
:
[],
...
@@ -982,7 +981,11 @@ def import_from_xml(xml, edx_video_id, resource_fs, static_dir, external_transcr
...
@@ -982,7 +981,11 @@ def import_from_xml(xml, edx_video_id, resource_fs, static_dir, external_transcr
edx_video_id
,
edx_video_id
,
course_id
,
course_id
,
)
)
if
course_id
:
# We don't want to link an existing video to course if its an external video.
# External videos do not have any playback profiles associated, these are just to track video
# transcripts for those video components who do not use edx hosted videos for playback.
if
course_id
and
video
.
status
!=
EXTERNAL_VIDEO_STATUS
:
course_video
,
__
=
CourseVideo
.
get_or_create_with_validation
(
video
=
video
,
course_id
=
course_id
)
course_video
,
__
=
CourseVideo
.
get_or_create_with_validation
(
video
=
video
,
course_id
=
course_id
)
image_file_name
=
xml
.
get
(
'image'
,
''
)
.
strip
()
image_file_name
=
xml
.
get
(
'image'
,
''
)
.
strip
()
...
...
edxval/models.py
View file @
ad63a296
...
@@ -33,6 +33,7 @@ logger = logging.getLogger(__name__) # pylint: disable=C0103
...
@@ -33,6 +33,7 @@ logger = logging.getLogger(__name__) # pylint: disable=C0103
URL_REGEX
=
r'^[a-zA-Z0-9\-_]*$'
URL_REGEX
=
r'^[a-zA-Z0-9\-_]*$'
LIST_MAX_ITEMS
=
3
LIST_MAX_ITEMS
=
3
EXTERNAL_VIDEO_STATUS
=
'external'
class
ModelFactoryWithValidation
(
object
):
class
ModelFactoryWithValidation
(
object
):
...
...
edxval/tests/constants.py
View file @
ad63a296
...
@@ -7,7 +7,8 @@ from edxval.models import (
...
@@ -7,7 +7,8 @@ from edxval.models import (
TranscriptProviderType
,
TranscriptProviderType
,
Cielo24Fidelity
,
Cielo24Fidelity
,
Cielo24Turnaround
,
Cielo24Turnaround
,
ThreePlayTurnaround
ThreePlayTurnaround
,
EXTERNAL_VIDEO_STATUS
)
)
from
edxval.utils
import
TranscriptFormat
from
edxval.utils
import
TranscriptFormat
...
@@ -136,6 +137,12 @@ VIDEO_DICT_DIFFERENT_ID_FISH = dict(
...
@@ -136,6 +137,12 @@ VIDEO_DICT_DIFFERENT_ID_FISH = dict(
edx_video_id
=
"medium-soaker"
,
edx_video_id
=
"medium-soaker"
,
status
=
"test"
,
status
=
"test"
,
)
)
EXTERNAL_VIDEO_DICT_FISH
=
dict
(
client_video_id
=
"External Video"
,
duration
=
0.0
,
edx_video_id
=
"external-video"
,
status
=
EXTERNAL_VIDEO_STATUS
,
)
ENCODED_VIDEO_DICT_FISH_MOBILE
=
dict
(
ENCODED_VIDEO_DICT_FISH_MOBILE
=
dict
(
url
=
"https://www.swordsingers.com"
,
url
=
"https://www.swordsingers.com"
,
file_size
=
9000
,
file_size
=
9000
,
...
...
edxval/tests/test_api.py
View file @
ad63a296
...
@@ -1431,6 +1431,26 @@ class ImportTest(TestCase):
...
@@ -1431,6 +1431,26 @@ class ImportTest(TestCase):
xml
=
self
.
make_import_xml
(
video_dict
=
constants
.
VIDEO_DICT_FISH
)
xml
=
self
.
make_import_xml
(
video_dict
=
constants
.
VIDEO_DICT_FISH
)
self
.
assert_invalid_import
(
xml
,
"x"
*
300
)
self
.
assert_invalid_import
(
xml
,
"x"
*
300
)
def
test_external_video_not_imported
(
self
):
"""
Verify that external videos are not imported into a course.
"""
# Setup an external Video.
Video
.
objects
.
create
(
**
constants
.
EXTERNAL_VIDEO_DICT_FISH
)
xml
=
self
.
make_import_xml
(
video_dict
=
constants
.
EXTERNAL_VIDEO_DICT_FISH
)
api
.
import_from_xml
(
xml
,
constants
.
EXTERNAL_VIDEO_DICT_FISH
[
'edx_video_id'
],
self
.
file_system
,
constants
.
EXPORT_IMPORT_STATIC_DIR
,
course_id
=
'test_course_id'
)
# Assert that the existing video is not imported into the course.
self
.
assertFalse
(
CourseVideo
.
objects
.
filter
(
course_id
=
'test_course_id'
,
video__edx_video_id
=
constants
.
EXTERNAL_VIDEO_DICT_FISH
[
'edx_video_id'
]
)
.
exists
())
def
test_external_no_video_transcript
(
self
):
def
test_external_no_video_transcript
(
self
):
"""
"""
Verify that transcript import for external video working as expected when there is no transcript.
Verify that transcript import for external video working as expected when there is no transcript.
...
...
setup.py
View file @
ad63a296
...
@@ -41,7 +41,7 @@ def load_requirements(*requirements_paths):
...
@@ -41,7 +41,7 @@ def load_requirements(*requirements_paths):
setup
(
setup
(
name
=
'edxval'
,
name
=
'edxval'
,
version
=
'0.1.1
6
'
,
version
=
'0.1.1
7
'
,
author
=
'edX'
,
author
=
'edX'
,
url
=
'http://github.com/edx/edx-val'
,
url
=
'http://github.com/edx/edx-val'
,
description
=
'edx-val'
,
description
=
'edx-val'
,
...
...
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