From c0bbd019260cbf929941306857fe0cf550b8bdc8 Mon Sep 17 00:00:00 2001 From: gzbender Date: Mon, 20 May 2019 21:11:09 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=BB=D0=B0=D0=B3=D0=B5=D1=80=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/course/templates/course/course_edit.html | 2 +- apps/user/templates/user/profile.html | 22 +++++++++++++++++-- apps/user/views.py | 14 +++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/apps/course/templates/course/course_edit.html b/apps/course/templates/course/course_edit.html index 29ef86cc..396839a0 100644 --- a/apps/course/templates/course/course_edit.html +++ b/apps/course/templates/course/course_edit.html @@ -17,7 +17,7 @@ {% endblock header_buttons %} {% block content %} - Перейти в онлайн-школу {% endif %} + {% if is_camp_purchased %} + + {% endif %} {% if user_gift_certificates.exists %} {% for ugs in user_gift_certificates %} {% cycle 'theme_pink2' 'theme_cyan' 'theme_violet2' as theme_color silent %} @@ -131,8 +147,10 @@ diff --git a/apps/user/views.py b/apps/user/views.py index fb5b47cb..8a80e4cd 100644 --- a/apps/user/views.py +++ b/apps/user/views.py @@ -24,7 +24,8 @@ from apps.config.models import Config from apps.course.models import Course from apps.notification.utils import send_email from apps.school.models import SchoolSchedule -from apps.payment.models import AuthorBalance, CoursePayment, SchoolPayment, Payment, UserGiftCertificate, UserBonus +from apps.payment.models import AuthorBalance, CoursePayment, SchoolPayment, Payment, UserGiftCertificate, UserBonus, \ + DrawingCampPayment from apps.user.models import AuthorRequest, EmailSubscription, SubscriptionCategory from .forms import AuthorRequesForm, UserEditForm, WithdrawalForm @@ -90,6 +91,17 @@ class ProfileView(TemplateView): context['school_purchased_price'] = aggregated.get('amount__sum') or 0 context['school_purchased_dates'] = [aggregated.get('date_start__min'), aggregated.get('date_end__max')] + camp_payment = DrawingCampPayment.objects.filter( + user=self.object, + date_end__gte=now(), + status__in=DrawingCampPayment.PW_PAID_STATUSES, + ) + context['is_camp_purchased'] = camp_payment.exists() + if context['is_camp_purchased']: + aggregated = camp_payment.aggregate(Sum('amount'), Min('date_start'), Max('date_end'),) + context['camp_purchased_price'] = aggregated.get('amount__sum') or 0 + context['camp_purchased_dates'] = [aggregated.get('date_start__min'), aggregated.get('date_end__max')] + context['profile'] = True return context