|
|
|
|
@ -151,7 +151,9 @@ class CourseEditView(TemplateView): |
|
|
|
|
template_name = 'course/course_edit.html' |
|
|
|
|
|
|
|
|
|
def get(self, request, pk=None): |
|
|
|
|
drafts = Course.objects.filter(author=request.user, status=Course.DRAFT) |
|
|
|
|
drafts = Course.objects.filter( |
|
|
|
|
author=request.user, status=Course.DRAFT |
|
|
|
|
) |
|
|
|
|
if pk: |
|
|
|
|
self.object = get_object_or_404(Course, pk=pk) |
|
|
|
|
elif drafts.exists(): |
|
|
|
|
@ -175,9 +177,7 @@ class CourseView(DetailView): |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
response = super().get(request, *args, **kwargs) |
|
|
|
|
if (self.object.status != Course.PUBLISHED and |
|
|
|
|
(request.user.role not in [User.AUTHOR_ROLE, User.ADMIN_ROLE] or |
|
|
|
|
self.object.author != request.user)): |
|
|
|
|
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 |
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|