|
|
|
|
@ -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 |
|
|
|
|
|