Skip to content

Commit

Permalink
HERA-663 404 when user with staff status on a course open Instructor …
Browse files Browse the repository at this point in the history
…tab (#2047)

Co-authored-by: Sagirov Eugeniy <[email protected]>
  • Loading branch information
sendr and UvgenGen authored May 8, 2020
1 parent c7765c8 commit d10e2ea
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lms/djangoapps/hera/middleware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.http import Http404, HttpResponseRedirect
from django.urls import reverse

from student.models import CourseEnrollmentAllowed
from courseware.access import has_access

from .models import UserOnboarding
from .utils import get_user_active_course_id
Expand Down Expand Up @@ -48,6 +48,10 @@ def process_request(self, request):
is_path_allowed = self.is_allowed(request.path, user)
is_ajax = request.META.get("HTTP_X_REQUESTED_WITH") == 'XMLHttpRequest'
if not user.is_staff:
if '/courses/' in request.path:
course_key = get_user_active_course_id(user)
if has_access(user, 'staff', course_key):
return
if not is_ajax and not is_path_allowed:
raise Http404
if '/media/' in request.path:
Expand Down

0 comments on commit d10e2ea

Please sign in to comment.