From a7c6a80adfd46a38f0f8f56f62c95ae65e8bcf97 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 14 Aug 2019 18:10:19 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D0=B0=20=D1=81=20=D1=86=D0=B5=D0=BD=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/school/views.py | 17 ++++++++++------- project/views.py | 11 ++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/school/views.py b/apps/school/views.py index 686f31af..c737f199 100644 --- a/apps/school/views.py +++ b/apps/school/views.py @@ -106,15 +106,15 @@ class LiveLessonsDetailView(DetailView): is_purchased = DrawingCampPayment.objects.all() else: is_purchased = SchoolPayment.objects.filter(weekdays__contains=[self.object.date.weekday() + 1],) - is_purchased = is_purchased.filter( + is_purchased = is_purchased.paid().filter( user=request.user, date_start__lte=now(), date_end__gte=now() - timedelta(days=7), - status__in=[ - Pingback.PINGBACK_TYPE_REGULAR, - Pingback.PINGBACK_TYPE_GOODWILL, - Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, - ], + ).exists() or is_purchased.paid().filter( + user=request.user, + date_start__lte=now(), + date_end__gte=now() - timedelta(days=30), + package__duration__lte=9, ).exists() if not is_purchased and request.user.role not in [User.ADMIN_ROLE, User.TEACHER_ROLE]: raise Http404 @@ -221,7 +221,10 @@ class SchoolView(TemplateView): # берем все подписки, которые были в периоде for sp in prev_school_payments: # берем все уроки в оплаченном промежутке - date_range = [max(sp.date_start, prev_range[0]), min(sp.date_end, prev_range[1])] + if sp.package and sp.package.duration >= 9: + date_range = [max(sp.date_start, date_now - timedelta(30)), min(sp.date_end, prev_range[1])] + else: + date_range = [max(sp.date_start, prev_range[0]), min(sp.date_end, prev_range[1])] prev_live_lessons += list(LiveLesson.objects.filter( date__range=date_range, deactivated_at__isnull=True, diff --git a/project/views.py b/project/views.py index c4439517..b74079af 100644 --- a/project/views.py +++ b/project/views.py @@ -162,12 +162,13 @@ class PackagesView(TemplateView): ).last() context['last_school_payment'] = last_school_payment if last_school_payment: + next_month = (last_school_payment.date_end + timedelta(1)).month context['next_buy_date'] = last_school_payment.date_end + timedelta(1) - context['school_months_left'] = (school_end.month - last_school_payment.date_end.month - if last_school_payment.date_end.month < school_end.month - else (school_end.month + 12) - last_school_payment.date_end.month) + 1 + context['school_months_left'] = (school_end.month - next_month + if next_month <= school_end.month + else (school_end.month + 13) - next_month) else: context['school_months_left'] = (school_end.month - today.month - if today.month < school_end.month - else (school_end.month + 12) - today.month) + 1 + if today.month <= school_end.month + else (school_end.month + 13) - today.month) return context