Commit cda23bc0 by Simon Chen Committed by Feanil Patel

Allow video object override on course_run level

parent 672cb7bc
...@@ -507,7 +507,7 @@ class CourseRunSerializer(MinimalCourseRunSerializer): ...@@ -507,7 +507,7 @@ class CourseRunSerializer(MinimalCourseRunSerializer):
help_text=_('Language in which the course is administered') help_text=_('Language in which the course is administered')
) )
transcript_languages = serializers.SlugRelatedField(many=True, read_only=True, slug_field='code') transcript_languages = serializers.SlugRelatedField(many=True, read_only=True, slug_field='code')
video = VideoSerializer() video = VideoSerializer(source='get_video')
seats = SeatSerializer(many=True) seats = SeatSerializer(many=True)
instructors = serializers.SerializerMethodField(help_text='This field is deprecated. Use staff.') instructors = serializers.SerializerMethodField(help_text='This field is deprecated. Use staff.')
staff = PersonSerializer(many=True) staff = PersonSerializer(many=True)
......
...@@ -731,6 +731,10 @@ class CourseRun(TimeStampedModel): ...@@ -731,6 +731,10 @@ class CourseRun(TimeStampedModel):
else: else:
return _('Upcoming') return _('Upcoming')
@property
def get_video(self):
return self.video or self.course.video
@classmethod @classmethod
def search(cls, query): def search(cls, query):
""" Queries the search index. """ Queries the search index.
......
...@@ -356,6 +356,12 @@ class CourseRunTests(TestCase): ...@@ -356,6 +356,12 @@ class CourseRunTests(TestCase):
def test_image_url(self): def test_image_url(self):
assert self.course_run.image_url == self.course_run.course.image_url assert self.course_run.image_url == self.course_run.course.image_url
def test_get_video(self):
assert self.course_run.get_video == self.course_run.video
self.course_run.video = None
self.course_run.save()
assert self.course_run.get_video == self.course_run.course.video
@ddt.ddt @ddt.ddt
class OrganizationTests(TestCase): class OrganizationTests(TestCase):
......
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