remotes/origin/hotfix/LIL-661
gzbender 8 years ago
parent 40e7cd31cf
commit c3c0e0a5b5
  1. 10
      apps/school/models.py
  2. 2
      apps/school/templates/school/livelessons_list.html
  3. 2
      apps/school/templates/summer/promo.html
  4. 4
      apps/school/templates/summer/schedule_purchased.html
  5. 3
      apps/school/urls.py
  6. 76
      apps/school/views.py
  7. 2
      apps/user/templates/user/profile.html
  8. 1
      project/templates/blocks/footer.html
  9. 11
      project/templates/blocks/header.html
  10. 2
      project/templates/blocks/promo.html

@ -1,9 +1,10 @@
import arrow
from datetime import datetime, timedelta
from datetime import datetime, timedelta, date
from django.conf import settings
from django.db import models
from django.urls import reverse_lazy
from django.utils.functional import cached_property
from django.utils.timezone import now
from project.mixins import BaseModel, DeactivatedMixin
@ -50,15 +51,18 @@ class SchoolSchedule(models.Model):
end_at = datetime.combine(now().today(), self.start_at) + timedelta(hours=1)
return self.start_at <= now().time() and end_at.time() >= now().time() and self.weekday == now().isoweekday()
@cached_property
def current_live_lesson(self):
now_time = now()
september2018 = date(2018, 9, 1)
date_start = max(september2018, now().date())
live_lesson = LiveLesson.objects.filter(
date__week_day=self.weekday % 7 + 1,
date__range=[now_time.date(), (now_time + timedelta(days=6)).date()],
date__range=[date_start, date_start + timedelta(days=6)],
deactivated_at__isnull=True,
).first()
return live_lesson
@cached_property
def previous_live_lesson(self):
now_time = now()
live_lesson = LiveLesson.objects.filter(

@ -9,7 +9,7 @@
<div class="kit__body">
<div class="lessons__list">
{% for livelesson in livelesson_list %}
<div class="lessons__item" v-for="(lesson, index) in lessons">
<div class="lessons__item">
<div class="lessons__actions lessons__actions__no-hover">
<a target="_blank" class="lessons__action" href="{% url 'school:lesson-detail' livelesson.id %}">
<svg class="icon icon-eye">

@ -5,7 +5,7 @@
<span class="main__bold">Lil School</span> — первая образовательная онлайн-платформа креативного мышления для детей
</div>
<div class="main__subtitle">
Присоединяйтесь в Рисовальный лагерь
Подписывайтесь на онлайн-школу
</div>
<div class="main__actions">
<a

@ -28,8 +28,8 @@
<label class="casing__switcher switcher">
<span class="switcher__wrap">
<a href="{% url 'school:summer-school' %}?is_previous=true" class="switcher__item{% if is_previous %} active{% endif %}">запись уроков</a>
<a href="{% url 'school:summer-school' %}" class="switcher__item{% if not is_previous %} active{% endif %}">новые уроки</a>
<a href="{% url 'school:school' %}?is_previous=true" class="switcher__item{% if is_previous %} active{% endif %}">запись уроков</a>
<a href="{% url 'school:school' %}" class="switcher__item{% if not is_previous %} active{% endif %}">новые уроки</a>
</span>
</label>
</div>

@ -3,12 +3,11 @@ from django.urls import path, include
from .views import (
LiveLessonsView, LiveLessonEditView,
LiveLessonsDetailView, SchoolView,
SchoolSchedulesPrintView, SummerSchoolView,
SchoolSchedulesPrintView,
)
urlpatterns = [
path('', SchoolView.as_view(), name='school'),
path('summer', SummerSchoolView.as_view(), name='summer-school'),
path('schedules/print', SchoolSchedulesPrintView.as_view(), name='school_schedules-print'),
path('lessons/', LiveLessonsView.as_view(), name='lessons'),
path('lessons/create', LiveLessonEditView.as_view(), name='lessons-create'),

@ -1,4 +1,4 @@
from datetime import datetime, timedelta
from datetime import datetime, timedelta, date
from paymentwall import Pingback
from django.contrib.auth import get_user_model
@ -34,19 +34,22 @@ class LiveLessonsView(ListView):
template_name = 'school/livelessons_list.html'
def get_queryset(self):
september2018 = date(2018, 9, 1)
date_start = (now() - timedelta(days=7)).date()
if date_start < september2018:
date_start = september2018
date_range = Q(
date__range=[
(now() - timedelta(days=7)).date(),
(now() + timedelta(days=10)).date(),
date_start,
date_start + timedelta(days=17),
]
)
queryset = LiveLesson.objects.filter(date_range)
if queryset.count() < 17:
start_date = now() - timedelta(days=7)
for i in range(18):
try:
LiveLesson.objects.create(
date=(start_date + timedelta(days=i)).date(),
date=date_start + timedelta(days=i),
)
except IntegrityError:
pass
@ -108,67 +111,6 @@ class LiveLessonEditView(TemplateView):
class SchoolView(TemplateView):
template_name = 'school/school.html'
def get_context_data(self):
context = super().get_context_data()
is_previous = 'is_previous' in self.request.GET
date_now = now().date()
now_time = now()
try:
school_schedule = SchoolSchedule.objects.get(weekday=now_time.isoweekday())
except SchoolSchedule.DoesNotExist:
online = False
else:
end_at = datetime.combine(now_time.today(), school_schedule.start_at)
online = (
school_schedule.start_at <= now_time.time() and
(end_at + timedelta(hours=1)).time() >= now_time.time() and
school_schedule.current_live_lesson()
)
if self.request.user.is_authenticated:
school_payment = SchoolPayment.objects.filter(
user=self.request.user,
status__in=[
Pingback.PINGBACK_TYPE_REGULAR,
Pingback.PINGBACK_TYPE_GOODWILL,
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED,
],
date_start__lte=date_now,
date_end__gte=date_now
)
school_payment_exists = school_payment.exists()
school_schedules_purchased = school_payment.annotate(
joined_weekdays=Func(F('weekdays'), function='unnest',)
).values_list('joined_weekdays', flat=True).distinct()
else:
school_payment_exists = False
school_schedules_purchased = []
if school_payment_exists and is_previous:
live_lessons = LiveLesson.objects.filter(
date__gte=school_payment.last().date_start,
date__range=[(now_time - timedelta(days=8)).date(), (now_time - timedelta(days=1)).date()],
deactivated_at__isnull=True,
)
live_lessons_exists = live_lessons.exists()
else:
live_lessons = None
live_lessons_exists = False
context.update({
'online': online,
'live_lessons': live_lessons,
'live_lessons_exists': live_lessons_exists,
'is_previous': is_previous,
'course_items': Course.objects.filter(status=Course.PUBLISHED)[:6],
'is_purchased': school_payment_exists,
'min_school_price': SchoolSchedule.objects.aggregate(Min('month_price'))['month_price__min'],
'school_schedules': SchoolSchedule.objects.all(),
'school_schedules_purchased': school_schedules_purchased,
'subscription_ends': school_payment.filter(add_days=False).first().date_end if school_payment_exists else None,
})
return context
class SummerSchoolView(TemplateView):
template_name = 'school/summer_school.html'
def get_context_data(self):
@ -191,7 +133,7 @@ class SummerSchoolView(TemplateView):
school_schedule.current_live_lesson()
)
school_schedules = SchoolSchedule.objects.all()
school_schedules = sorted(SchoolSchedule.objects.all(), key=lambda ss: ss.current_live_lesson.date)
school_schedules_dict = {ss.weekday: ss for ss in school_schedules}
school_schedules_dict[0] = school_schedules_dict.get(7)
all_schedules_purchased = []

@ -88,7 +88,7 @@
{% else %}
<div class="center center_xs">
<div class="done">
<div class="done__title title">Вы не подписаны на лагерь!</div>
<div class="done__title title">Вы не подписаны на онлайн-школу!</div>
<div class="done__foot">
<a
{% if not user.is_authenticated %}

@ -19,7 +19,6 @@
<div class="footer__col">
<div class="footer__title">Программы</div>
<nav class="footer__nav">
<a class="footer__link" href="{% url 'school:summer-school' %}">Лагерь</a>
<a class="footer__link" href="{% url 'school:school' %}">Онлайн-школа</a>
<a class="footer__link" href="{% url 'courses' %}">Онлайн-курсы</a>
<a class="footer__link" href="{% url 'author_request' %}">Стать автором</a>

@ -25,22 +25,13 @@
</form>
</div>
<nav class="header__nav">
<div class="header__group">
<a class="header__section {% active_link 'school:summer-school' %}" href="{% url 'school:summer-school' %}">
ОНЛАЙН-ШКОЛА {% if online or livelesson.is_online %}
<div class="header__dot"></div>
{% endif %}
</a>
</div>
{% comment %}
<div class="header__group">
<a class="header__section {% active_link 'school:school' %}" href="{% url 'school:school' %}">
ОНЛАЙН-ШКОЛА {% if online or livelesson.is_online %}
<!--<div class="header__dot"></div>-->
<div class="header__dot"></div>
{% endif %}
</a>
</div>
{% endcomment %}
<div class="header__group">
<a class="header__section header__section_sub js-header-section {% active_link 'courses' %}" href="{% url 'courses' %}">ВИДЕО-КУРСЫ</a>
<div class="header__list js-header-list">

@ -46,7 +46,6 @@
</div>
{% else %}
<div class="main__subtitle">
{# Присоединяйтесь в Рисовальный лагерь #}
Приглашаем вас на месяц открытых дверей в Lil School
</div>
<div class="main__actions">
@ -67,7 +66,6 @@
</a>
{% endif %}
{% endcomment %}
{# <a class="main__btn btn btn_white" href="{% url 'school:summer-school' %}">О лагере</a> #}
<a class="main__btn btn btn_white" href="{% url 'course' pk=50 %}">Подробнее</a>
</div>
{% endif %}

Loading…
Cancel
Save