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

Feat: Add lesson thumbnail on Models.py

parent 1594a665
......@@ -731,6 +731,12 @@ class Lesson(PositionedModel):
default=STATES[0][0],
max_length=64,
)
thumbnail = models.ImageField(
_('Thumbnail'),
upload_to=hash_name('lesson_thumbnails', 'name'),
null=True,
blank=True,
)
collection_name = 'course'
......@@ -738,6 +744,15 @@ 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')
......
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