diff --git a/apps/content/models.py b/apps/content/models.py index d4135f12..872d8044 100644 --- a/apps/content/models.py +++ b/apps/content/models.py @@ -99,7 +99,7 @@ class Video(Content): url = models.URLField('Ссылка') def video_index(self): - if 'youtu.be' in self.url or 'youtube.com' in self.url and 'watch' in self.url: + if self.is_youtube_video: url = urlparse(self.url) query = url.query.split('&') for q in query: @@ -107,6 +107,14 @@ class Video(Content): return q.split('=')[-1] return self.url.split('/')[-1] + @property + def is_youtube_video(self): + return 'youtu.be' in self.url or 'youtube.com' in self.url and 'watch' in self.url + + @property + def is_vimeo_video(self): + return 'vimeo.com' in self.url + class Gallery(Content): pass diff --git a/apps/content/templates/content/blocks/video.html b/apps/content/templates/content/blocks/video.html index 8c707388..fc4bd60c 100644 --- a/apps/content/templates/content/blocks/video.html +++ b/apps/content/templates/content/blocks/video.html @@ -4,12 +4,12 @@ {{ content.title }}
- {% if 'youtube.com' in content.url or 'youtu.be' in content.url %} - - {% elif 'vimeo.com' in content.url %} - + {% elif content.is_vimeo_video %} + {% endif %}
diff --git a/apps/school/templates/school/livelesson_detail.html b/apps/school/templates/school/livelesson_detail.html index 9ee47ad8..d7a8dcdb 100644 --- a/apps/school/templates/school/livelesson_detail.html +++ b/apps/school/templates/school/livelesson_detail.html @@ -33,6 +33,10 @@ width="720" height="400" webkitallowfullscreen mozallowfullscreen allowfullscreen> + + {% include 'templates/blocks/popup_school_lesson_ended.html' %} Если видео не загрузилось, - уменьшите качество видео или обновите страницу @@ -60,12 +64,13 @@ {% endblock content %} {% block foot %} + {% if livelesson.stream_index %} diff --git a/project/templates/blocks/popup_school_lesson_ended.html b/project/templates/blocks/popup_school_lesson_ended.html new file mode 100644 index 00000000..12404388 --- /dev/null +++ b/project/templates/blocks/popup_school_lesson_ended.html @@ -0,0 +1,15 @@ +{% load static %} +