Merge branch 'master' of https://gitlab.com/lilcity/backend into feature/lil-583

remotes/origin/hotfix/LIL-691
gzbender 8 years ago
commit c6e721d722
  1. 4
      apps/course/templates/course/course.html
  2. 6
      apps/course/templates/course/course_only_lessons.html
  3. 31
      apps/course/views.py
  4. 2
      apps/school/templates/summer/schedule_purchased.html
  5. 5
      apps/school/views.py
  6. 87
      apps/user/templates/user/author_profile.html
  7. 2
      apps/user/templates/user/notification-settings.html
  8. 2
      apps/user/templates/user/payment-history.html
  9. 2
      apps/user/templates/user/profile-settings.html
  10. 24
      apps/user/templates/user/profile.html
  11. 44
      apps/user/views.py
  12. 4
      project/templates/blocks/popup_course_lock.html
  13. 66
      project/templates/blocks/promo.html
  14. 4
      project/templates/blocks/user_menu.html
  15. 7
      project/urls.py

@ -158,13 +158,13 @@
{% else %}
<a
class="course__action btn btn_lg{% if only_lessons %} btn_stroke{% else %} btn_gray{% endif %}"
{% if paid %}
{% if paid or not course.price %}
href="{% url 'course-only-lessons' course.id %}"
{% else %}
data-popup=".js-popup-course-lock"
{% endif %}
>УРОКИ
{% if not paid %}
{% if not paid and course.price %}
<svg class="icon icon-lock">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-lock"></use>
</svg>

@ -25,7 +25,7 @@
</div>
<div class="go__title">Вернуться</div>
</a>
{% if not paid and course.price %}
{% if not paid and course.price and not has_full_access %}
<a
class="go__btn btn{% if pending %} btn_gray{% endif %} btn_md"
{% if user.is_authenticated %}
@ -154,10 +154,10 @@
</a>
{% else %}
<a
href="{% if paid %}{% url 'course-only-lessons' course.id %}{% else %}#{% endif %}"
href="{% if paid or not course.price %}{% url 'course-only-lessons' course.id %}{% else %}#{% endif %}"
class="course__action btn btn_lg{% if only_lessons %} btn_stroke{% else %} btn_gray{% endif %}"
>УРОКИ
{% if not paid %}
{% if not paid and course.price %}
<svg class="icon icon-lock">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-lock"></use>
</svg>

@ -189,9 +189,13 @@ class CourseView(DetailView):
def get(self, request, *args, **kwargs):
response = super().get(request, *args, **kwargs)
context = self.get_context_data()
if (not request.user.is_authenticated and self.object.status != Course.PUBLISHED) or\
(request.user.is_authenticated and request.user.role < User.AUTHOR_ROLE and self.object.author != request.user and self.only_lessons and not context['paid']):
raise Http404
# если это не админ или автор
if not context.get('has_full_access'):
# если это не опубл курс или это страница уроков, курс платный, а юзер не оплатил курс - 404
if (self.object.status != Course.PUBLISHED) or \
(self.only_lessons and self.object.price and not context.get('paid')):
raise Http404
return response
# ((self.object.status != Course.PUBLISHED and request.user.role != User.ADMIN_ROLE) or
@ -216,6 +220,9 @@ class CourseView(DetailView):
context['only_lessons'] = self.only_lessons
if self.only_lessons:
context['lessons'] = self.object.lessons.order_by('position')
context['is_owner'] = self.object.author == self.request.user
context['is_admin'] = self.request.user.role == User.ADMIN_ROLE
context['has_full_access'] = context['is_owner'] or context['is_admin']
return context
def get_queryset(self):
@ -292,10 +299,20 @@ class LessonView(DetailView):
def get(self, request, *args, **kwargs):
response = super().get(request, *args, **kwargs)
if (self.object.course.status != Course.PUBLISHED and not
(request.user.role == User.ADMIN_ROLE or
self.object.course.author == request.user)):
raise Http404
paid = request.user.is_authenticated and self.object.course.payments.filter(
user=self.request.user,
status__in=[
Pingback.PINGBACK_TYPE_REGULAR,
Pingback.PINGBACK_TYPE_GOODWILL,
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED,
],
).exists()
# если это не автор или админ
if not (request.user.is_authenticated and
(request.user.role == User.ADMIN_ROLE or self.object.course.author == request.user)):
# если курс не опубликован или он платный и не оплачен - 404
if self.object.course.status != Course.PUBLISHED or (self.object.course.price and not paid):
raise Http404
return response
def get_context_data(self, **kwargs):

@ -43,7 +43,7 @@
{% else %}
{% if is_previous %}
{% for live_lesson in live_lessons %}
{% if live_lesson.school_schedule %}
{% if live_lesson.school_schedule and live_lesson.title %}
{% include 'blocks/schedule_item.html' with school_schedule=live_lesson.school_schedule live_lesson=live_lesson purchased=True %}
{% endif %}
{% endfor %}

@ -181,7 +181,8 @@ class SummerSchoolView(TemplateView):
is_previous = 'is_previous' in self.request.GET
date_now = now().date()
yesterday = date_now - timedelta(days=1)
month_start = date_now.replace(day=1)
# month_start = date_now.replace(day=1)
month_start = datetime(2018, 7, 1).date()
now_time = now()
try:
school_schedule = SchoolSchedule.objects.get(weekday=now_time.isoweekday())
@ -211,7 +212,7 @@ class SummerSchoolView(TemplateView):
).annotate(
joined_weekdays=Func(F('weekdays'), function='unnest',)
).distinct().values_list('joined_weekdays', flat=True)
all_schedules_purchased = map(lambda x: 1 if x == 7 else x+1, all_schedules_purchased)
all_schedules_purchased = list(map(lambda x: 1 if x == 7 else x+1, all_schedules_purchased))
school_payment = SchoolPayment.objects.filter(
user=self.request.user,

@ -0,0 +1,87 @@
{% extends "templates/lilcity/index.html" %} {% load static %} {% load thumbnail %} {% block content %}
<div class="section">
<div class="section__center center">
<div class="profile">
<div class="profile__ava ava">
{% thumbnail user.photo "120x120" crop="center" as im %}
<img class="ava__pic" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
{% empty %}
<img class="ava__pic" src="{% static 'img/user_default.jpg' %}" width="120px" height="120px" />
{% endthumbnail %}
</div>
<div class="profile__wrap">
<div class="profile__name">{{ user.get_full_name }}</div>
<div class="profile__share share share_sm">
<div class="share__list">
{% if user.facebook %}
<a class="share__item" href="{{ user.facebook }}">
<svg class="icon icon-share-facebook">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-share-facebook"></use>
</svg>
</a>
{% endif %} {% if user.instagram %}
<a class="share__item" href="{{ user.instagram }}">
<svg class="icon icon-share-instagram">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-share-instagram"></use>
</svg>
</a>
{% endif %} {% if user.twitter %}
<a class="share__item" href="{{ user.twitter }}">
<svg class="icon icon-share-twitter">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-share-twitter"></use>
</svg>
</a>
{% endif %} {% if user.google %}
<a class="share__item" href="{{ user.google }}">
<svg class="icon icon-share-google">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-share-google"></use>
</svg>
</a>
{% endif %} {% if user.pinterest %}
<a class="share__item" href="{{ user.pinterest }}">
<svg class="icon icon-share-pinterest">
<use xlink:href="{% static 'img/sprite.svg' %}#icon-share-pinterest"></use>
</svg>
</a>
{% endif %}
</div>
</div>
</div>
<div class="profile__content">
{% if user.about %}
{{ user.about }}
{% endif %}
</div>
</div>
</div>
</div>
<div class="section section_pink-light section_tabs">
<div class="section__center center">
<div class="tabs js-tabs">
<div class="tabs__nav">
<button class="tabs__btn js-tabs-btn {% if not owner %}active{% endif %}">ОПУБЛИКОВАННЫЕ
<span class="mobile-hide">КУРСЫ</span>
</button>
</div>
<div class="tabs__container">
<div class="tabs__item js-tabs-item" style="display: block;">
<div class="courses courses_scroll">
<div class="courses__list">
{% if published.exists %}
{% include "course/course_items.html" with course_items=published %}
{% else %}
<div class="center center_xs">
<div class="done">
<div class="done__title title">Нет опубликованных курсов!</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock content %}

@ -2,7 +2,7 @@
<div class="section section_gray section_menu">
<div class="section__center center center_xs">
<div class="menu">
<a class="menu__link" href="{% url 'user-edit-profile' user.id %}">Профиль</a>
<a class="menu__link" href="{% url 'user-edit-profile' %}">Профиль</a>
<a class="menu__link active" href="{% url 'user-edit-notifications' user.id %}">Уведомления</a>
<a class="menu__link" href="{% url 'user-edit-payments' user.id %}">Платежи</a>
</div>

@ -2,7 +2,7 @@
<div class="section section_gray section_menu">
<div class="section__center center center_xs">
<div class="menu">
<a class="menu__link" href="{% url 'user-edit-profile' user.id %}">Профиль</a>
<a class="menu__link" href="{% url 'user-edit-profile' %}">Профиль</a>
<a class="menu__link" href="{% url 'user-edit-notifications' user.id %}">Уведомления</a>
<a class="menu__link active" href="{% url 'user-edit-payments' user.id %}">Платежи</a>
</div>

@ -2,7 +2,7 @@
<div class="section section_gray section_menu">
<div class="section__center center center_xs">
<div class="menu">
<a class="menu__link active" href="{% url 'user-edit-profile' user.id %}">Профиль</a>
<a class="menu__link active" href="{% url 'user-edit-profile' %}">Профиль</a>
<a class="menu__link" href="{% url 'user-edit-notifications' user.id %}">Уведомления</a>
<a class="menu__link" href="{% url 'user-edit-payments' user.id %}">Платежи</a>
</div>

@ -2,9 +2,7 @@
<div class="section">
<div class="section__center center">
<div class="profile">
{% if not guest %}
<a class="profile__btn profile__btn_edit btn" href="{% url 'user-edit-profile' user.id %}">Редактировать</a>
{% endif %}
<a class="profile__btn profile__btn_edit btn" href="{% url 'user-edit-profile' %}">Редактировать</a>
<div class="profile__ava ava">
{% thumbnail user.photo "120x120" crop="center" as im %}
<img class="ava__pic" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
@ -56,7 +54,7 @@
{% endif %}
</div>
<div class="profile__foot">
<a class="profile__btn btn" href="{% url 'user-edit-profile' user.id %}">Изменить</a>
<a class="profile__btn btn" href="{% url 'user-edit-profile' %}">Изменить</a>
</div>
</div>
</div>
@ -66,18 +64,18 @@
<div class="section__center center">
<div class="tabs js-tabs">
<div class="tabs__nav">
{% if owner %}
<button class="tabs__btn js-tabs-btn active">ЛАГЕРЬ</button>
{# <button class="tabs__btn js-tabs-btn active">ЛАГЕРЬ</button> #}
<button class="tabs__btn js-tabs-btn">ПРИОБРЕТЕННЫЕ
<span class="mobile-hide">КУРСЫ</span>
</button>
{% endif %}
<button class="tabs__btn js-tabs-btn {% if not owner %}active{% endif %}">ОПУБЛИКОВАННЫЕ
{% if is_author %}
<button class="tabs__btn js-tabs-btn">ОПУБЛИКОВАННЫЕ
<span class="mobile-hide">КУРСЫ</span>
</button>
{% endif %}
</div>
<div class="tabs__container">
{% if owner %}
{% comment %}
<div class="tabs__item js-tabs-item" style="display: block;">
{% if is_purchased_future %}
<div class="center center_xs">
@ -108,7 +106,8 @@
{% endif %}
{% endif %}
</div>
<div class="tabs__item js-tabs-item">
{% endcomment %}
<div class="tabs__item js-tabs-item" style="display: block;">
<div class="courses courses_scroll">
<div class="courses__list">
{% if paid.exists %}
@ -126,8 +125,8 @@
</div>
</div>
</div>
{% endif %}
<div class="tabs__item js-tabs-item" {% if not owner %}style="display: block;"{% endif %}>
{% if is_author %}
<div class="tabs__item js-tabs-item">
<div class="courses courses_scroll">
<div class="courses__list">
{% if published.exists %}
@ -145,6 +144,7 @@
</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>

@ -41,25 +41,23 @@ def resend_email_verify(request):
url = request.scheme + '://' + request.get_host() + str(reverse_lazy('lilcity:verification-email', args=[token, request.user.id]))
send_email('Вы успешно прошли регистрацию', request.user.email, "notification/email/verification_email.html", url=url)
messages.info(request, 'Письмо подтверждения отправлено.')
return redirect('user-edit-profile', request.user.id)
return redirect('user-edit-profile')
class UserView(DetailView):
@method_decorator(login_required, name='dispatch')
class ProfileView(TemplateView):
model = User
template_name = 'user/profile.html'
def get(self, request, *args, **kwargs):
self.object = self.request.user
context = self.get_context_data(object=self.object)
return self.render_to_response(context)
def get_context_data(self, object):
context = super().get_context_data()
if not self.request.user.is_anonymous:
context['simple_user'] = self.request.user.role == User.USER_ROLE
context['guest'] = self.request.user.id != self.object.id and self.request.user.role <= User.USER_ROLE
else:
context['simple_user'] = True
context['guest'] = True
context['owner'] = self.request.user.id == self.object.id
if context['guest'] and self.object.role <= User.USER_ROLE:
raise Http404()
context['user'] = self.request.user
context['is_author'] = self.request.user.role == User.AUTHOR_ROLE
context['published'] = Course.objects.filter(
author=self.object,
@ -110,6 +108,18 @@ class UserView(DetailView):
return context
class UserView(DetailView):
model = User
template_name = 'user/author_profile.html'
def get_context_data(self, object):
context = super().get_context_data()
context['published'] = Course.objects.filter(
author=self.object,
)
return context
class SubscribeView(View):
def post(self, request, pk=None, **kwargs):
@ -190,16 +200,16 @@ class PaymentHistoryView(FormView):
@method_decorator(login_required, name='dispatch')
class UserEditView(UpdateView):
class ProfileEditView(UpdateView):
model = User
template_name = 'user/profile-settings.html'
form_class = UserEditForm
@method_decorator(login_required)
def get_object(self, queryset=None):
return self.request.user
def dispatch(self, request, *args, **kwargs):
self.object = self.get_object()
if request.user != self.object:
raise Http404()
return super().dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
@ -245,7 +255,7 @@ class UserEditView(UpdateView):
return super().post(request, *args, **kwargs)
def get_success_url(self):
return reverse('user-edit-profile', args=[self.object.id])
return reverse('user-edit-profile')
class AuthorRequestView(FormView):

@ -5,8 +5,8 @@
<div class="popup__body">
<div class="lock">
<div class="lock__label">ЧТОБЫ ПРОДОЛЖИТЬ ПРОСМОТР</div>
<div class="lock__title title">Как просто научиться рисовать простых персонажей.</div>
<div class="lock__content">Этот курс поможет детям узнать о том как из простых форм создавать веселый и харизматичных персонажей.</div>
<div class="lock__title title">{{ course.title }}</div>
<div class="lock__content">{{ course.short_description }}</div>
<a href="{% url 'course-checkout' course.id %}" class="lock__btn btn">КУПИТЬ КУРС</a>
</div>
</div>

@ -11,39 +11,39 @@
<div class="main__title">
<span class="main__bold">Lil School</span> — первая образовательная онлайн-платформа креативного мышления для детей
</div>
{% if user.is_authenticated and online %}
<div class="main__content">
Сейчас идёт прямой эфир урока «{{ school_schedule.title }}, {{ school_schedule.current_live_lesson.title }}»
</div>
<div class="main__actions">
<a
{% if not is_purchased %}
data-popup=".js-popup-buy"
href='#'
{% else %}
href="{{ school_schedule.current_live_lesson.get_absolute_url }}"
{% endif %}
class="main__btn btn"
>{% if not is_purchased %}Получить доступ{% else %}Смотреть урок{% endif %}</a>
</div>
{% elif user.is_authenticated and online_coming_soon and school_schedule and school_schedule.start_at_humanize %}
<div class="">
Урок «{{ school_schedule.title }}, {{ school_schedule.current_live_lesson.title }}» начнётся
</div>
<div class="main__time">
{{ school_schedule.start_at_humanize }}
</div>
<div class="main__actions">
<a
{% if not is_purchased %}
data-popup=".js-popup-buy"
href='#'
{% else %}
href="{{ school_schedule.current_live_lesson.get_absolute_url }}"
{% endif %}
class="main__btn btn"
>{% if not is_purchased %}Получить доступ{% else %}Смотреть урок{% endif %}</a>
</div>
{% if False and user.is_authenticated and online %}
<div class="main__content">
Сейчас идёт прямой эфир урока «{{ school_schedule.title }}, {{ school_schedule.current_live_lesson.title }}»
</div>
<div class="main__actions">
<a
{% if not is_purchased %}
data-popup=".js-popup-buy"
href='#'
{% else %}
href="{{ school_schedule.current_live_lesson.get_absolute_url }}"
{% endif %}
class="main__btn btn"
>{% if not is_purchased %}Получить доступ{% else %}Смотреть урок{% endif %}</a>
</div>
{% elif False and user.is_authenticated and online_coming_soon and school_schedule and school_schedule.start_at_humanize %}
<div class="">
Урок «{{ school_schedule.title }}, {{ school_schedule.current_live_lesson.title }}» начнётся
</div>
<div class="main__time">
{{ school_schedule.start_at_humanize }}
</div>
<div class="main__actions">
<a
{% if not is_purchased %}
data-popup=".js-popup-buy"
href='#'
{% else %}
href="{{ school_schedule.current_live_lesson.get_absolute_url }}"
{% endif %}
class="main__btn btn"
>{% if not is_purchased %}Получить доступ{% else %}Смотреть урок{% endif %}</a>
</div>
{% else %}
<div class="main__subtitle">
{# Присоединяйтесь в Рисовальный лагерь #}

@ -1,7 +1,7 @@
{% load static %} {% load thumbnail %}
{% if request.user.is_authenticated %}
<div class="header__login">
<a class="header__ava ava" href="{% if request.user_agent.is_touch_capable %}#{% else %}{% url 'user' request.user.id %}{% endif %}">
<a class="header__ava ava" href="{% if request.user_agent.is_touch_capable %}#{% else %}{% url 'user-profile' %}{% endif %}">
{% thumbnail request.user.photo "48x48" crop="center" as im %}
<img class="ava__pic" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
{% empty %}
@ -26,7 +26,7 @@
{% endif %}
{% endif %}
{% endif %}
<a class="header__link" href="{% url 'user' request.user.id %}">
<a class="header__link" href="{% url 'user-profile' %}">
<div class="header__title">ПРОФИЛЬ</div>
</a>
<a class="header__link" href="{% url 'lilcity:logout' %}">

@ -27,9 +27,9 @@ from apps.course.views import (
)
from apps.user.views import (
AuthorRequestView, UserView,
UserEditView, NotificationEditView,
ProfileEditView, NotificationEditView,
PaymentHistoryView, resend_email_verify,
SubscribeView,
SubscribeView, ProfileView,
)
from apps.payment.views import (
CourseBuySuccessView, CourseBuyView,
@ -67,8 +67,9 @@ urlpatterns = [
path('payments/error', TemplateView.as_view(template_name='payment/payment_error.html'), name='payment-error'),
path('school/checkout', SchoolBuyView.as_view(), name='school-checkout'),
path('search/', SearchView.as_view(), name='search'),
path('user/profile/', ProfileView.as_view(), name='user-profile'),
path('user/profile/edit', ProfileEditView.as_view(), name='user-edit-profile'),
path('user/<int:pk>/', UserView.as_view(), name='user'),
path('user/<int:pk>/edit', UserEditView.as_view(), name='user-edit-profile'),
path('user/<int:pk>/notifications', NotificationEditView.as_view(), name='user-edit-notifications'),
path('user/<int:pk>/payments', PaymentHistoryView.as_view(), name='user-edit-payments'),
path('user/resend-email-verify', resend_email_verify, name='resend-email-verify'),

Loading…
Cancel
Save