remotes/origin/hotfix/LIL-691
gzbender 7 years ago
parent a266ec6afc
commit d4b8893825
  1. 2
      apps/school/templates/blocks/schedule_item.html
  2. 2
      apps/school/templates/school/summer_school.html
  3. 10
      apps/school/templates/summer/schedule_purchased.html
  4. 63
      apps/school/views.py

@ -13,7 +13,7 @@
{% endif %}
<div class="timing__time">{{ school_schedule.start_at }} (МСК)</div>
<div class="timing__buy">
{% if is_purchased and school_schedule.weekday in school_schedules_purchased %}
{% if is_purchased and school_schedule.weekday in school_schedules_purchased or is_previous %}
{% if live_lesson and live_lesson.title %}
{% include './open_lesson.html' %}
{% endif %}

@ -2,7 +2,7 @@
{% block title %}Онлайн-школа LilCity{% endblock title%}
{% block ogimage %}http://{{request.META.HTTP_HOST}}{% static 'img/og_main.jpg' %}{% endblock %}
{% block content %}
{% if not is_purchased %}
{% if not is_purchased and not prev_school_payments_exists %}
{% include "../summer/promo.html" %}
{% include "../summer/about.html" %}
{% include "../summer/advantages.html" %}

@ -5,9 +5,15 @@
<div class="casing">
<div class="casing__col">
<div class="casing__subscribe">
{% if is_purchased %}
<div class="casing__msg">Подписка истекает
<span class="bold">{{ subscription_ends }}</span>
</div>
{% else %}
<div class="casing__msg">Подписка
<span class="bold">истекла</span>
</div>
{% endif %}
{% if allow_prolong %}
{% include './prolong_btn.html' with pink=True %}
{% endif %}
@ -38,12 +44,12 @@
{% if is_previous %}
{% for live_lesson in live_lessons %}
{% if live_lesson.school_schedule and live_lesson.title %}
{% include 'blocks/schedule_item.html' with school_schedule=live_lesson.school_schedule live_lesson=live_lesson purchased=True %}
{% include 'blocks/schedule_item.html' with school_schedule=live_lesson.school_schedule live_lesson=live_lesson %}
{% endif %}
{% endfor %}
{% else %}
{% for school_schedule in school_schedules_sorted %}
{% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson purchased=True %}
{% include 'blocks/schedule_item.html' with school_schedule=school_schedule live_lesson=school_schedule.current_live_lesson %}
{% endfor %}
{% endif %}
{% endif %}

@ -111,8 +111,6 @@ class SchoolView(TemplateView):
is_previous = 'is_previous' in self.request.GET
date_now = now().date()
yesterday = date_now - timedelta(days=1)
# month_start = date_now.replace(day=1)
month_start = datetime(2018, 7, 1).date()
now_time = now()
try:
school_schedule = SchoolSchedule.objects.get(weekday=now_time.isoweekday())
@ -128,14 +126,18 @@ class SchoolView(TemplateView):
school_schedules = SchoolSchedule.objects.all()
try:
school_schedules_sorted = sorted(school_schedules, key=lambda ss: ss.current_live_lesson and ss.current_live_lesson.date)
school_schedules_sorted = sorted(school_schedules,
key=lambda ss: ss.current_live_lesson and ss.current_live_lesson.date)
except Exception:
pass
school_schedules_dict = {ss.weekday: ss for ss in school_schedules}
school_schedules_dict[0] = school_schedules_dict.get(7)
live_lessons = None
live_lessons = []
live_lessons_exists = False
subscription_ends = None
school_payment_exists = False
school_schedules_purchased = []
school_purchased_future = False
prev_school_payments = None
prev_range = [date_now - timedelta(days=8), date_now]
if self.request.user.is_authenticated:
school_payment = SchoolPayment.objects.filter(
user=self.request.user,
@ -161,15 +163,8 @@ class SchoolView(TemplateView):
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 = []
school_purchased_future = False
if is_previous:
prev_range = [yesterday - timedelta(days=7), date_now]
live_lessons = []
# берем все подписки, которые были в периоде
for sp in SchoolPayment.objects.filter(
prev_school_payments = SchoolPayment.objects.filter(
date_start__lt=prev_range[1],
date_end__gte=prev_range[0],
user=self.request.user,
@ -178,21 +173,28 @@ class SchoolView(TemplateView):
Pingback.PINGBACK_TYPE_GOODWILL,
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED,
],
):
# берем все уроки в оплаченном промежутке
date_range = [max(sp.date_start, prev_range[0]), min(sp.date_end, prev_range[1])]
live_lessons += LiveLesson.objects.filter(
date__range=date_range,
deactivated_at__isnull=True,
date__week_day__in=list(map(lambda x: 1 if x == 7 else x+1, sp.weekdays)),
).values_list('id', flat=True)
live_lessons = LiveLesson.objects.filter(id__in=set(live_lessons)).order_by('-date')
live_lessons_exists = live_lessons.exists()
if live_lessons_exists:
for ll in live_lessons:
ll.school_schedule = school_schedules_dict.get(ll.date.isoweekday())
else:
live_lessons = None
weekdays__len__gt=0,
)
if is_previous:
# берем все подписки, которые были в периоде
for sp in prev_school_payments:
# берем все уроки в оплаченном промежутке
date_range = [max(sp.date_start, prev_range[0]), min(sp.date_end, prev_range[1])]
live_lessons += LiveLesson.objects.filter(
date__range=date_range,
deactivated_at__isnull=True,
date__week_day__in=list(map(lambda x: 1 if x == 7 else x+1, sp.weekdays)),
).values_list('id', flat=True)
live_lessons = LiveLesson.objects.filter(id__in=set(live_lessons)).order_by('-date')
live_lessons_exists = live_lessons.exists()
if live_lessons_exists:
school_schedules_dict = {ss.weekday: ss for ss in school_schedules}
school_schedules_dict[0] = school_schedules_dict.get(7)
for ll in live_lessons:
ll.school_schedule = school_schedules_dict.get(ll.date.isoweekday())
else:
live_lessons = []
context.update({
'online': online,
@ -207,6 +209,7 @@ class SchoolView(TemplateView):
'school_schedules': school_schedules,
'school_schedules_purchased': school_schedules_purchased,
'school_purchased_future': school_purchased_future,
'prev_school_payments_exists': prev_school_payments and prev_school_payments.exists(),
'subscription_ends': subscription_ends,
'prolong_date_start': subscription_ends + timedelta(days=1) if subscription_ends else None,
'allow_prolong': subscription_ends - date_now <= timedelta(days=7)

Loading…
Cancel
Save