Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
b7b69550
Commit
b7b69550
authored
Apr 13, 2020
by
Fernando Ribeiro
Browse files
Feat: Add working version of lesson thumbnail
parent
cc89466b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
9 deletions
+3
-9
courses/models.py
courses/models.py
+3
-9
No files found.
courses/models.py
View file @
b7b69550
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment