Проблемы с воспроизведением уроков

remotes/origin/hotfix/vimeo-fix
gzbender 7 years ago
parent cda9df3cd0
commit 01e25c1d08
  1. 10
      apps/auth/views.py
  2. 21
      apps/school/templates/school/livelesson_detail.html
  3. 5
      apps/school/views.py

@ -9,13 +9,14 @@ from facepy.exceptions import FacepyError
from django.contrib.auth import get_user_model, logout, login, views from django.contrib.auth import get_user_model, logout, login, views
from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.forms import AuthenticationForm
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.http import JsonResponse from django.http import JsonResponse, Http404
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.views.generic import FormView, View, TemplateView from django.views.generic import FormView, View, TemplateView
from django.views.generic.edit import BaseFormView from django.views.generic.edit import BaseFormView
from django.shortcuts import redirect from django.shortcuts import redirect
from django.conf import settings
from apps.notification.utils import send_email from apps.notification.utils import send_email
from apps.config.models import Config from apps.config.models import Config
@ -126,15 +127,16 @@ class PasswordResetView(views.PasswordContextMixin, BaseFormView):
title = 'Password reset' title = 'Password reset'
token_generator = views.default_token_generator token_generator = views.default_token_generator
def get(self, *args, **kwargs):
raise Http404()
def form_valid(self, form): def form_valid(self, form):
refferer = urlsplit(self.request.META.get('HTTP_REFERER'))
refferer = str(refferer[0]) + '://' + str(refferer[1])
config = Config.load() config = Config.load()
extra_email_context = {'config': config} extra_email_context = {'config': config}
if self.extra_email_context and isinstance(self.extra_email_context, dict): if self.extra_email_context and isinstance(self.extra_email_context, dict):
extra_email_context.update(self.extra_email_context) extra_email_context.update(self.extra_email_context)
opts = { opts = {
'domain_override': refferer, 'domain_override': 'https://' + settings.MAIN_HOST,
'use_https': self.request.is_secure(), 'use_https': self.request.is_secure(),
'token_generator': self.token_generator, 'token_generator': self.token_generator,
'from_email': self.from_email, 'from_email': self.from_email,

@ -15,6 +15,12 @@
{% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.height }}{% else %}{{ block.super }}{% endif %} {% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.height }}{% else %}{{ block.super }}{% endif %}
{% endblock ogimage-height %} {% endblock ogimage-height %}
{% block head %}
{% if livelesson.stream_index %}
<script src="https://player.vimeo.com/api/player.js"></script>
{% endif %}
{% endblock head %}
{% block content %} {% block content %}
<div class="section" style="margin-bottom:0;padding-bottom:0"> <div class="section" style="margin-bottom:0;padding-bottom:0">
<div class="section__center center center_sm"> <div class="section__center center center_sm">
@ -23,8 +29,9 @@
<div class="lesson__content">{{ livelesson.short_description | safe | linebreaks }}</div> <div class="lesson__content">{{ livelesson.short_description | safe | linebreaks }}</div>
<div class="lesson__video video"> <div class="lesson__video video">
{% if livelesson.stream_index %} {% if livelesson.stream_index %}
<iframe class="lesson__video_frame" src="https://player.vimeo.com/video/{{ livelesson.stream_index }}?autoplay=1" frameborder="0" webkitallowfullscreen <iframe class="lesson__video_frame" src="https://player.vimeo.com/video/{{ livelesson.stream_index }}" frameborder="0"
mozallowfullscreen allowfullscreen> width="720" height="400"
webkitallowfullscreen mozallowfullscreen allowfullscreen>
</iframe> </iframe>
<span>Если видео не загрузилось, - уменьшите качество видео или <a href="#" onclick="location.reload();">обновите страницу</a></span> <span>Если видео не загрузилось, - уменьшите качество видео или <a href="#" onclick="location.reload();">обновите страницу</a></span>
<!--<iframe class="lesson__chat_frame" src="https://vimeo.com/live-chat/{{ livelesson.stream_index }}" frameborder="0"></iframe>--> <!--<iframe class="lesson__chat_frame" src="https://vimeo.com/live-chat/{{ livelesson.stream_index }}" frameborder="0"></iframe>-->
@ -51,3 +58,13 @@
</div> </div>
</div> </div>
{% endblock content %} {% endblock content %}
{% block foot %}
{% if livelesson.stream_index %}
<script>
var iframe = document.querySelector('iframe.lesson__video_frame');
var player = new Vimeo.Player(iframe);
player.play();
</script>
{% endif %}
{% endblock foot %}

@ -65,7 +65,10 @@ class LiveLessonsDetailView(DetailView):
if pk: if pk:
self.object = self.get_object() self.object = self.get_object()
if lesson_date: if lesson_date:
self.object = LiveLesson.objects.get(date=datetime.strptime(lesson_date, '%d-%m-%y')) try:
self.object = LiveLesson.objects.get(date=datetime.strptime(lesson_date, '%d-%m-%y'))
except Exception:
raise Http404()
if request.user.is_authenticated: if request.user.is_authenticated:
is_purchased = SchoolPayment.objects.filter( is_purchased = SchoolPayment.objects.filter(
user=request.user, user=request.user,

Loading…
Cancel
Save