+ {% endif %}
{% if paid.exists %}
{% include "course/course_items.html" with course_items=paid %}
- {% else %}
+ {% endif %}
+ {% if not is_school_purchased and not paid.exists %}
-
Нет приобретённых курсов!
+
Вы пока ничего не приобрели...
diff --git a/apps/user/views.py b/apps/user/views.py
index b2765a79..249a1b41 100644
--- a/apps/user/views.py
+++ b/apps/user/views.py
@@ -14,7 +14,7 @@ from django.views.generic import DetailView, UpdateView, TemplateView, FormView
from django.contrib import messages
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
-from django.db.models import F, Func
+from django.db.models import F, Func, Sum, Min, Max
from django.urls import reverse_lazy
from django.utils.decorators import method_decorator
from django.utils.timezone import now
@@ -53,11 +53,11 @@ class ProfileView(TemplateView):
def get_context_data(self, object):
context = super().get_context_data()
context['user'] = self.request.user
- context['is_author'] = self.request.user.role == User.AUTHOR_ROLE
context['published'] = Course.objects.filter(
author=self.object,
)
+ context['is_author'] = context['published'] or self.request.user.role == User.AUTHOR_ROLE
context['paid'] = Course.objects.filter(
payments__in=CoursePayment.objects.filter(
user=self.object,
@@ -78,22 +78,18 @@ class ProfileView(TemplateView):
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED,
],
)
- school_schedules_purchased = school_payment.annotate(
- joined_weekdays=Func(F('weekdays'), function='unnest',)
- ).values_list('joined_weekdays', flat=True).distinct()
- context['school_schedules_purchased'] = school_schedules_purchased
- context['school_payment'] = school_payment
- context['is_purchased'] = school_payment.exists()
- context['profile'] = True
- if school_payment.exists() and school_payment.last().date_end:
- context['subscription_ends'] = school_payment.last().date_end
- context['school_schedules'] = SchoolSchedule.objects.filter(
- weekday__in=school_schedules_purchased if school_payment.exists() else [],
- ).all()
- context['all_school_schedules'] = SchoolSchedule.objects.all()
+ context['is_school_purchased'] = school_payment.exists()
+ if context['is_school_purchased']:
+ school_schedules_purchased = school_payment.annotate(
+ joined_weekdays=Func(F('weekdays'), function='unnest',)
+ ).values_list('joined_weekdays', flat=True).distinct()
+ aggregated = school_payment.aggregate(Sum('amount'), Min('date_start'), Max('date_end'),)
+ context['school_purchased_weekdays'] = '-'.join(map(lambda wd: SchoolSchedule.WEEKDAY_SHORT_NAMES[wd-1],
+ set(sorted(school_schedules_purchased))))
+ context['school_purchased_price'] = aggregated.get('amount__sum') or 0
+ context['school_purchased_dates'] = [aggregated.get('date_start__min'), aggregated.get('date_end__max')]
- context['is_purchased_future'] = False
- context['school_purchased_future'] = False
+ context['profile'] = True
return context
@@ -105,7 +101,7 @@ class UserView(DetailView):
def get_context_data(self, object):
context = super().get_context_data()
context['published'] = Course.objects.filter(
- author=self.object,
+ author=self.object, status=Course.PUBLISHED,
)
return context
diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass
index 8aacd9d1..d8d5924d 100755
--- a/web/src/sass/_common.sass
+++ b/web/src/sass/_common.sass
@@ -1710,6 +1710,8 @@ a.grey-link
color: $cl
+t
line-height: 1.33
+ &__theme
+ text-transform: uppercase
&__user
margin-top: 20px
&_two &__item