Commit 42428504 by muhammad-ammar

update

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