From 2c1c3ed0619549169d134433c9368e1467631c64 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 29 May 2019 13:38:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D0=B0=D0=BF=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=86=D0=B5=20=D0=B2=D0=B8=D0=B4=D0=B5=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/content/models.py | 10 +++++++++- apps/content/templates/content/blocks/video.html | 12 ++++++------ .../templates/school/livelesson_detail.html | 12 ++++++++++-- .../blocks/popup_school_lesson_ended.html | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 project/templates/blocks/popup_school_lesson_ended.html 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 %} +