From 22f314637b1c004786302d7b65daf70bed992bbd Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 1 Aug 2018 20:45:31 +0500 Subject: [PATCH 1/2] =?UTF-8?q?LIL-607=20=D0=94=D0=BE=D1=81=D1=82=D1=83?= =?UTF-8?q?=D0=BF=20=D0=BA=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B5=20?= =?UTF-8?q?=D1=83=D1=80=D0=BE=D0=BA=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=20=D0=BD=D0=B5=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/course/templates/course/course.html | 4 ++-- .../templates/course/course_only_lessons.html | 4 ++-- apps/course/views.py | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/course/templates/course/course.html b/apps/course/templates/course/course.html index 15a54c12..53a56abc 100644 --- a/apps/course/templates/course/course.html +++ b/apps/course/templates/course/course.html @@ -158,13 +158,13 @@ {% else %} УРОКИ - {% if not paid %} + {% if not paid and course.price %} diff --git a/apps/course/templates/course/course_only_lessons.html b/apps/course/templates/course/course_only_lessons.html index fd0d489c..ff56ca65 100644 --- a/apps/course/templates/course/course_only_lessons.html +++ b/apps/course/templates/course/course_only_lessons.html @@ -154,10 +154,10 @@ {% else %} УРОКИ - {% if not paid %} + {% if not paid and course.price %} diff --git a/apps/course/views.py b/apps/course/views.py index 8cff720a..4a6a2658 100644 --- a/apps/course/views.py +++ b/apps/course/views.py @@ -190,7 +190,8 @@ class CourseView(DetailView): 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']): + (request.user.is_authenticated and request.user.role != User.ADMIN_ROLE and self.object.author != request.user + and self.only_lessons and self.object.price and not context['paid']): raise Http404 return response @@ -292,7 +293,15 @@ class LessonView(DetailView): def get(self, request, *args, **kwargs): response = super().get(request, *args, **kwargs) - if (self.object.course.status != Course.PUBLISHED and not + paid = 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 ((self.object.course.status != Course.PUBLISHED or (self.object.course.price and not paid)) and not (request.user.role == User.ADMIN_ROLE or self.object.course.author == request.user)): raise Http404 From 8b5954c3f25ca12a707d16b283ba706eaf5caad3 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 1 Aug 2018 21:39:31 +0500 Subject: [PATCH 2/2] LIL-607 popup --- project/templates/blocks/popup_course_lock.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/templates/blocks/popup_course_lock.html b/project/templates/blocks/popup_course_lock.html index 75053862..45f87ae0 100644 --- a/project/templates/blocks/popup_course_lock.html +++ b/project/templates/blocks/popup_course_lock.html @@ -5,8 +5,8 @@