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 %} +
+ + +
Подробнее
+
+
+   +
{{ camp_purchased_price|floatformat:"-2" }}₽
+
+ Лагерь {{ camp_purchased_dates.0|date:"j b" }} - {{ camp_purchased_dates.1|date:"j b" }} + + Перейти в лагерь +
+ {% 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