remotes/origin/feature/LIL-711
gzbender 7 years ago
parent 0603352001
commit 3a8d2024ef
  1. 15
      apps/course/templates/course/course.html
  2. 6
      apps/school/templates/school/livelesson_detail.html
  3. 27
      apps/school/templates/school/livelesson_detail_unauth.html
  4. 30
      apps/school/views.py

@ -8,9 +8,18 @@
{% block twurl %}{{ request.build_absolute_uri }}{% endblock twurl %} {% block twurl %}{{ request.build_absolute_uri }}{% endblock twurl %}
{% block ogtitle %}{{ course.title }} - {{ block.super }}{% endblock ogtitle %} {% block ogtitle %}{{ course.title }} - {{ block.super }}{% endblock ogtitle %}
{% block ogurl %}{{ request.build_absolute_uri }}{% endblock ogurl %} {% block ogurl %}{{ request.build_absolute_uri }}{% endblock ogurl %}
{% if course.cover and course.cover.image %}
{% block ogimage %}http://{{request.META.HTTP_HOST}}{% if course.cover %}{{ course.cover.image.url }}{% else %}{% static 'img/og_courses.jpg' %}{% endif %}{% endblock ogimage %} {% block ogimage %}
{% endif %} http://{{request.META.HTTP_HOST}}{% if course.cover and course.cover.image %}{{ course.cover.image.url }}{% else %}{% static 'img/og_courses.jpg' %}{% endif %}
{% endblock ogimage %}
{% block ogimage-width %}
{% if course.cover and course.cover.image %}{{ course.cover.image.width }}{% else %}1024{% endif %}
{% endblock ogimage-width %}
{% block ogimage-height %}
{% if course.cover and course.cover.image %}{{ course.cover.image.height }}{% else %}512{% endif %}
{% endblock ogimage-height %}
{% block ogdescription %}{{ course.short_description | striptags }}{% endblock ogdescription %} {% block ogdescription %}{{ course.short_description | striptags }}{% endblock ogdescription %}
{% block content %} {% block content %}

@ -8,6 +8,12 @@
{% block ogimage %} {% block ogimage %}
{% if livelesson.cover and livelesson.cover.image %}http://{{request.META.HTTP_HOST}}{{ livelesson.cover.image.url }}{% else %}{{ block.super }}{% endif %} {% if livelesson.cover and livelesson.cover.image %}http://{{request.META.HTTP_HOST}}{{ livelesson.cover.image.url }}{% else %}{{ block.super }}{% endif %}
{% endblock ogimage %} {% endblock ogimage %}
{% block ogimage-width %}
{% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.width }}{% else %}{{ block.super }}{% endif %}
{% endblock ogimage-width %}
{% block ogimage-height %}
{% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.height }}{% else %}{{ block.super }}{% endif %}
{% endblock ogimage-height %}
{% block content %} {% block content %}
<div class="section" style="margin-bottom:0;padding-bottom:0"> <div class="section" style="margin-bottom:0;padding-bottom:0">

@ -0,0 +1,27 @@
{% extends "templates/lilcity/index.html" %}
{% load static %}
{% block title %}{{ livelesson.title }} - {{ block.super }}{% endblock title %}
{% block twurl %}{{ request.build_absolute_uri }}{% endblock twurl %}
{% block ogtitle %}{{ livelesson.title }} - {{ block.super }}{% endblock ogtitle %}
{% block ogurl %}{{ request.build_absolute_uri }}{% endblock ogurl %}
{% block ogimage %}
{% if livelesson.cover and livelesson.cover.image %}http://{{request.META.HTTP_HOST}}{{ livelesson.cover.image.url }}{% else %}{{ block.super }}{% endif %}
{% endblock ogimage %}
{% block ogimage-width %}
{% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.width }}{% else %}{{ block.super }}{% endif %}
{% endblock ogimage-width %}
{% block ogimage-height %}
{% if livelesson.cover and livelesson.cover.image %}{{ livelesson.cover.image.height }}{% else %}{{ block.super }}{% endif %}
{% endblock ogimage-height %}
{% block content %}
<div class="section">
<div class="section__center center center_sm">
<div class="title">
Чтобы посмотреть урок необходимо авторизоваться
</div>
<button class="btn" data-popup=".js-popup-auth">Войти</button>
</div>
</div>
{% endblock content %}

@ -57,26 +57,28 @@ class LiveLessonsView(ListView):
return queryset return queryset
@method_decorator(login_required, name='dispatch')
class LiveLessonsDetailView(DetailView): class LiveLessonsDetailView(DetailView):
model = LiveLesson model = LiveLesson
template_name = 'school/livelesson_detail.html' template_name = 'school/livelesson_detail.html'
def get(self, request, pk=None): def get(self, request, pk=None):
self.object = self.get_object() self.object = self.get_object()
is_purchased = SchoolPayment.objects.filter( if request.user.is_authenticated:
user=request.user, is_purchased = SchoolPayment.objects.filter(
date_start__lte=now(), user=request.user,
date_end__gte=now() - timedelta(days=7), date_start__lte=now(),
status__in=[ date_end__gte=now() - timedelta(days=7),
Pingback.PINGBACK_TYPE_REGULAR, status__in=[
Pingback.PINGBACK_TYPE_GOODWILL, Pingback.PINGBACK_TYPE_REGULAR,
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, Pingback.PINGBACK_TYPE_GOODWILL,
], Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED,
weekdays__contains=[self.object.date.weekday() + 1], ],
).exists() weekdays__contains=[self.object.date.weekday() + 1],
if not is_purchased and request.user.role not in [User.ADMIN_ROLE, User.TEACHER_ROLE]: ).exists()
raise Http404 if not is_purchased and request.user.role not in [User.ADMIN_ROLE, User.TEACHER_ROLE]:
raise Http404
else:
self.template_name = 'school/livelesson_detail_unauth.html'
context = self.get_context_data(object=self.object) context = self.get_context_data(object=self.object)
return self.render_to_response(context) return self.render_to_response(context)

Loading…
Cancel
Save