|
|
|
@ -56,56 +56,62 @@ class UserView(DetailView): |
|
|
|
else: |
|
|
|
else: |
|
|
|
context['simple_user'] = True |
|
|
|
context['simple_user'] = True |
|
|
|
context['guest'] = True |
|
|
|
context['guest'] = True |
|
|
|
context['owner'] = self.request.user.id == self.object.id |
|
|
|
owner = self.request.user.id == self.object.id |
|
|
|
|
|
|
|
|
|
|
|
if context['guest'] and self.object.role <= User.USER_ROLE: |
|
|
|
if context['guest'] and self.object.role <= User.USER_ROLE: |
|
|
|
raise Http404() |
|
|
|
raise Http404() |
|
|
|
|
|
|
|
|
|
|
|
context['published'] = Course.objects.filter( |
|
|
|
published = Course.objects.filter( |
|
|
|
author=self.object, |
|
|
|
author=self.object, |
|
|
|
) |
|
|
|
) |
|
|
|
context['paid'] = Course.objects.filter( |
|
|
|
if not owner: |
|
|
|
payments__in=CoursePayment.objects.filter( |
|
|
|
published = published.filter(status=Course.PUBLISHED) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
context['paid'] = Course.objects.filter( |
|
|
|
|
|
|
|
payments__in=CoursePayment.objects.filter( |
|
|
|
|
|
|
|
user=self.object, |
|
|
|
|
|
|
|
status__in=[ |
|
|
|
|
|
|
|
Pingback.PINGBACK_TYPE_REGULAR, |
|
|
|
|
|
|
|
Pingback.PINGBACK_TYPE_GOODWILL, |
|
|
|
|
|
|
|
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
).distinct() |
|
|
|
|
|
|
|
school_payment = SchoolPayment.objects.filter( |
|
|
|
user=self.object, |
|
|
|
user=self.object, |
|
|
|
|
|
|
|
date_start__lte=now(), |
|
|
|
|
|
|
|
date_end__gt=now(), |
|
|
|
status__in=[ |
|
|
|
status__in=[ |
|
|
|
Pingback.PINGBACK_TYPE_REGULAR, |
|
|
|
Pingback.PINGBACK_TYPE_REGULAR, |
|
|
|
Pingback.PINGBACK_TYPE_GOODWILL, |
|
|
|
Pingback.PINGBACK_TYPE_GOODWILL, |
|
|
|
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, |
|
|
|
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
) |
|
|
|
).distinct() |
|
|
|
school_schedules_purchased = school_payment.annotate( |
|
|
|
school_payment = SchoolPayment.objects.filter( |
|
|
|
joined_weekdays=Func(F('weekdays'), function='unnest',) |
|
|
|
user=self.object, |
|
|
|
).values_list('joined_weekdays', flat=True).distinct() |
|
|
|
date_start__lte=now(), |
|
|
|
context['school_schedules_purchased'] = school_schedules_purchased |
|
|
|
date_end__gt=now(), |
|
|
|
context['school_payment'] = school_payment |
|
|
|
status__in=[ |
|
|
|
context['is_purchased'] = school_payment.exists() |
|
|
|
Pingback.PINGBACK_TYPE_REGULAR, |
|
|
|
context['profile'] = True |
|
|
|
Pingback.PINGBACK_TYPE_GOODWILL, |
|
|
|
if school_payment.exists() and school_payment.last().date_end: |
|
|
|
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, |
|
|
|
context['subscription_ends'] = school_payment.last().date_end |
|
|
|
], |
|
|
|
context['school_schedules'] = SchoolSchedule.objects.filter( |
|
|
|
) |
|
|
|
weekday__in=school_schedules_purchased if school_payment.exists() else [], |
|
|
|
school_schedules_purchased = school_payment.annotate( |
|
|
|
).all() |
|
|
|
joined_weekdays=Func(F('weekdays'), function='unnest',) |
|
|
|
context['all_school_schedules'] = SchoolSchedule.objects.all() |
|
|
|
).values_list('joined_weekdays', flat=True).distinct() |
|
|
|
|
|
|
|
context['school_schedules_purchased'] = school_schedules_purchased |
|
|
|
school_payment_future = SchoolPayment.objects.filter( |
|
|
|
context['school_payment'] = school_payment |
|
|
|
user=self.object, |
|
|
|
context['is_purchased'] = school_payment.exists() |
|
|
|
date_start__gte=now(), |
|
|
|
context['profile'] = True |
|
|
|
date_end__gte=now() |
|
|
|
if school_payment.exists() and school_payment.last().date_end: |
|
|
|
) |
|
|
|
context['subscription_ends'] = school_payment.last().date_end |
|
|
|
|
|
|
|
context['school_schedules'] = SchoolSchedule.objects.filter( |
|
|
|
context['is_purchased_future'] = school_payment_future.exists() |
|
|
|
weekday__in=school_schedules_purchased if school_payment.exists() else [], |
|
|
|
context['school_purchased_future'] = school_payment_future.last() |
|
|
|
).all() |
|
|
|
|
|
|
|
context['all_school_schedules'] = SchoolSchedule.objects.all() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
school_payment_future = SchoolPayment.objects.filter( |
|
|
|
|
|
|
|
user=self.object, |
|
|
|
|
|
|
|
date_start__gte=now(), |
|
|
|
|
|
|
|
date_end__gte=now() |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context['is_purchased_future'] = school_payment_future.exists() |
|
|
|
context['owner'] = owner |
|
|
|
context['school_purchased_future'] = school_payment_future.last() |
|
|
|
context['published'] = published |
|
|
|
|
|
|
|
|
|
|
|
return context |
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|