Commit 42428504 by muhammad-ammar

update

parent 56cff78f
......@@ -489,7 +489,6 @@ def copy_course_videos(source_course_id, destination_course_id):
try:
VideoImage.create_or_update(
course_video=dest_course_video,
image_data=None,
file_name=course_video.video_image.image.name
)
except VideoImage.DoesNotExist:
......@@ -573,7 +572,8 @@ def import_from_xml(xml, edx_video_id, course_id=None):
image_file_name = xml.get('image', '').strip()
if image_file_name:
VideoImage.create_or_update(course_video, None, image_file_name)
VideoImage.create_or_update(course_video, image_file_name)
return
except ValidationError as err:
logger.exception(err.message)
......@@ -586,10 +586,9 @@ def import_from_xml(xml, edx_video_id, course_id=None):
'edx_video_id': edx_video_id,
'client_video_id': xml.get('client_video_id'),
'duration': xml.get('duration'),
'image': xml.get('image'),
'status': 'imported',
'encoded_videos': [],
'courses': [course_id] if course_id else [],
'courses': [{course_id: xml.get('image')}] if course_id else [],
}
for encoded_video_el in xml.iterfind('encoded_video'):
profile_name = encoded_video_el.get('profile')
......
......@@ -164,7 +164,6 @@ class VideoSerializer(serializers.ModelSerializer):
Create the video and its nested resources.
"""
courses = validated_data.pop("courses", [])
image = validated_data.pop("image", None)
encoded_videos = validated_data.pop("encoded_videos", [])
subtitles = validated_data.pop("subtitles", [])
......@@ -214,7 +213,6 @@ class VideoSerializer(serializers.ModelSerializer):
for subtitle_data in validated_data.get("subtitles", [])
)
image = validated_data.get("image")
# Set courses
# NOTE: for backwards compatibility with the DRF v2 behavior,
# we do NOT delete existing course videos during the update.
......
......@@ -797,7 +797,7 @@ class TestCopyCourse(TestCase):
# 1st video
self.video1 = Video.objects.create(**constants.VIDEO_DICT_FISH)
self.course_video1 = CourseVideo.objects.create(video=self.video1, course_id=self.course_id)
VideoImage.create_or_update(self.course_video1, None, self.image_name1)
VideoImage.create_or_update(self.course_video1, self.image_name1)
# 2nd video
self.video2 = Video.objects.create(**constants.VIDEO_DICT_STAR)
CourseVideo.objects.create(video=self.video2, course_id=self.course_id)
......@@ -870,7 +870,7 @@ class ExportTest(TestCase):
Video.objects.create(**constants.VIDEO_DICT_STAR)
video = Video.objects.create(**constants.VIDEO_DICT_FISH)
course_video = CourseVideo.objects.create(video=video, course_id='test-course')
VideoImage.create_or_update(course_video, None, 'image.jpg')
VideoImage.create_or_update(course_video, 'image.jpg')
EncodedVideo.objects.create(
video=video,
......@@ -1062,7 +1062,8 @@ class ImportTest(TestCase):
"bitrate": 1597804,
"profile": "mobile",
},
]
],
image=self.image_name
)
api.import_from_xml(xml, constants.VIDEO_DICT_FISH["edx_video_id"], course_id)
......@@ -1076,6 +1077,8 @@ class ImportTest(TestCase):
video.encoded_videos.filter(profile__profile_name=constants.PROFILE_DESKTOP).exists()
)
self.assertTrue(video.courses.filter(course_id=course_id).exists())
course_video = video.courses.get(course_id=course_id)
self.assertTrue(course_video.video_image.image.name, self.image_name)
def test_existing_video_with_invalid_course_id(self):
......
......@@ -39,7 +39,7 @@ def load_requirements(*requirements_paths):
setup(
name='edxval',
version='0.0.14',
version='0.0.14x',
author='edX',
url='http://github.com/edx/edx-val',
description='edx-val',
......
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