Commit b7b69550 authored by Fernando Ribeiro's avatar Fernando Ribeiro
Browse files

Feat: Add working version of lesson thumbnail

parent cc89466b
......@@ -744,15 +744,7 @@ class Lesson(PositionedModel):
def is_course_last_lesson(self):
lessons = list(self.course.public_lessons)
return len(lessons) > 0 and self == lessons[-1]
@property
def thumbnail_url(self):
return self.get_thumbnail_url()
def get_thumbnail_url(self):
if self.thumbnail:
return self.thumbnail
return ''
class Meta:
verbose_name = _('Lesson')
......@@ -763,12 +755,14 @@ class Lesson(PositionedModel):
return self.name
@property
def thumbnail(self):
def thumbnail_url(self):
try:
first_vid_unit = self.units.exclude(video=None).order_by('position')[0]
thumbnail = 'http://i1.ytimg.com/vi/' + first_vid_unit.video.youtube_id + '/hqdefault.jpg'
return thumbnail
except IndexError:
if self.thumbnail:
return self.thumbnail.url
return staticfiles_storage.url('img/lesson-default.png')
def activity_count(self):
......
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