From 257b3aa8ab17293788396c1a9c5d205e1fb546a7 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Mon, 2 Jul 2018 13:57:47 +0300 Subject: [PATCH] LIL-557. Add coming soon button --- apps/school/models.py | 4 ++++ project/templates/blocks/promo.html | 30 +++++++++++++++++++++++++++-- project/views.py | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/apps/school/models.py b/apps/school/models.py index f1dcc168..35788640 100644 --- a/apps/school/models.py +++ b/apps/school/models.py @@ -2,6 +2,7 @@ import arrow from datetime import datetime, timedelta from django.db import models +from django.urls import reverse_lazy from django.utils.timezone import now from project.mixins import BaseModel, DeactivatedMixin @@ -126,6 +127,9 @@ class LiveLesson(BaseModel, DeactivatedMixin): self.date = (datetime.combine(self.date, now().time()) + timedelta(days=1)).date() super().save(*args, **kwargs) + def get_absolute_url(self): + return reverse_lazy('school:lesson-detail', args=[str(self.id)]) + def stream_index(self): return self.stream.split('/')[-1] diff --git a/project/templates/blocks/promo.html b/project/templates/blocks/promo.html index a4faf5f6..8fa641f4 100644 --- a/project/templates/blocks/promo.html +++ b/project/templates/blocks/promo.html @@ -11,13 +11,39 @@
Lil School — первая образовательная онлайн-платформа креативного мышления для детей
- {% if online_coming_soon and school_schedule and school_schedule.start_at_humanize %} + {% if user.is_authenticated and online %}
- До начала урока «{{ school_schedule.title }}» + Сейчас идёт прямой эфир урока «{{ school_schedule.title }}» +
+
+ {% if not is_purchased %}Получить доступ{% else %}Смотреть урок{% endif %} +
+ {% elif user.is_authenticated and online_coming_soon and school_schedule and school_schedule.start_at_humanize %} +
+ Урок «{{ school_schedule.title }}» начнётся
{{ school_schedule.start_at_humanize }}
+
+ {% if not is_purchased %}Получить доступ{% else %}Смотреть урок{% endif %} +
{% else %}
Присоединяйтесь в Рисовальный лагерь diff --git a/project/views.py b/project/views.py index ea165c91..17395e62 100644 --- a/project/views.py +++ b/project/views.py @@ -39,7 +39,7 @@ class IndexView(TemplateView): online_coming_soon = ( school_schedule.start_at > now_time.time() and ( - datetime.combine(datetime.today(), school_schedule.start_at) - timedelta(hours=5) + datetime.combine(datetime.today(), school_schedule.start_at) - timedelta(hours=12) ).time() <= now_time.time() and school_schedule.current_live_lesson() )