Fix LIL-572 Незареганные пользователи видят черновики

remotes/origin/hotfix/lil-572
gzbender 8 years ago
parent e43e890114
commit 8fb1fe5a8d
  1. 72
      apps/user/templates/user/profile.html
  2. 80
      apps/user/views.py

@ -78,54 +78,54 @@
</div>
<div class="tabs__container">
{% if owner %}
<div class="tabs__item js-tabs-item" style="display: block;">
{% if is_purchased_future %}
<div class="center center_xs">
<div class="done">
<div class="done__title title">Ваша подписка начинается {{school_purchased_future.date_start}}</div>
</div>
</div>
{% else %}
{% if is_purchased %}
{% include "blocks/schedule_purchased.html" %}
{% else %}
<div class="center center_xs">
<div class="done">
<div class="done__title title">Вы не подписаны на лагерь!</div>
<div class="done__foot">
<a
{% if not user.is_authenticated %}
data-popup=".js-popup-auth"
{% else %}
data-popup=".js-popup-buy"
{% endif %}
href="#"
class="done__btn btn btn_md btn_stroke"
>Купить подписку</a>
<div class="tabs__item js-tabs-item" style="display: block;">
{% if is_purchased_future %}
<div class="center center_xs">
<div class="done">
<div class="done__title title">Ваша подписка начинается {{school_purchased_future.date_start}}</div>
</div>
</div>
</div>
{% endif %}
{% endif %}
</div>
<div class="tabs__item js-tabs-item">
<div class="courses courses_scroll">
<div class="courses__list">
{% if paid.exists %}
{% include "course/course_items.html" with course_items=paid %}
{% else %}
{% if is_purchased %}
{% include "blocks/schedule_purchased.html" %}
{% else %}
<div class="center center_xs">
<div class="done">
<div class="done__title title">Нет приобретённых курсов!</div>
<div class="done__title title">Вы не подписаны на лагерь!</div>
<div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{% url 'courses' %}">Купить курсы</a>
<a
{% if not user.is_authenticated %}
data-popup=".js-popup-auth"
{% else %}
data-popup=".js-popup-buy"
{% endif %}
href="#"
class="done__btn btn btn_md btn_stroke"
>Купить подписку</a>
</div>
</div>
</div>
{% endif %}
{% endif %}
</div>
<div class="tabs__item js-tabs-item">
<div class="courses courses_scroll">
<div class="courses__list">
{% if paid.exists %}
{% include "course/course_items.html" with course_items=paid %}
{% else %}
<div class="center center_xs">
<div class="done">
<div class="done__title title">Нет приобретённых курсов!</div>
<div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{% url 'courses' %}">Купить курсы</a>
</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
<div class="tabs__item js-tabs-item" {% if not owner %}style="display: block;"{% endif %}>
<div class="courses courses_scroll">

@ -56,56 +56,62 @@ class UserView(DetailView):
else:
context['simple_user'] = 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:
raise Http404()
context['published'] = Course.objects.filter(
published = Course.objects.filter(
author=self.object,
)
context['paid'] = Course.objects.filter(
payments__in=CoursePayment.objects.filter(
if not owner:
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,
date_start__lte=now(),
date_end__gt=now(),
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,
date_start__lte=now(),
date_end__gt=now(),
status__in=[
Pingback.PINGBACK_TYPE_REGULAR,
Pingback.PINGBACK_TYPE_GOODWILL,
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()
school_payment_future = SchoolPayment.objects.filter(
user=self.object,
date_start__gte=now(),
date_end__gte=now()
)
)
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()
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['school_purchased_future'] = school_payment_future.last()
context['is_purchased_future'] = school_payment_future.exists()
context['school_purchased_future'] = school_payment_future.last()
context['owner'] = owner
context['published'] = published
return context

Loading…
Cancel
Save