|
|
|
|
@ -166,7 +166,7 @@ class CourseView(DetailView): |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
response = super().get(request, *args, **kwargs) |
|
|
|
|
if (self.object != Course.PUBLISHED and |
|
|
|
|
if (self.object.status != Course.PUBLISHED and |
|
|
|
|
(request.user.role not in [User.AUTHOR_ROLE, User.ADMIN_ROLE] or |
|
|
|
|
self.object.author != request.user)): |
|
|
|
|
raise Http404 |
|
|
|
|
@ -241,11 +241,20 @@ class CoursesView(ListView): |
|
|
|
|
return 'course/courses.html' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@method_decorator(login_required, name='dispatch') |
|
|
|
|
class LessonView(DetailView): |
|
|
|
|
model = Lesson |
|
|
|
|
context_object_name = 'lesson' |
|
|
|
|
template_name = 'course/lesson.html' |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
response = super().get(request, *args, **kwargs) |
|
|
|
|
if (self.object.course.status != Course.PUBLISHED and |
|
|
|
|
(request.user.role not in [User.AUTHOR_ROLE, User.ADMIN_ROLE] or |
|
|
|
|
self.object.course.author != request.user)): |
|
|
|
|
raise Http404 |
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SearchView(CoursesView): |
|
|
|
|
template_name = 'course/result.html' |
|
|
|
|
|