feat!: raise 404 for old mongo course pages (#31125)

LMS Courseware access to Old Mongo courses was already removed in
fc8601de (https://github.com/openedx/edx-platform/pull/30172). This
commit makes direct links to the other tabs (progress, instructor
dashboard, discussion, static tabs) fail with a 404 error on Old
Mongo courses.

Upcoming work to remove parent/child relationships from the Old
Mongo Modulestore would have broken these pages anyway.
This commit is contained in:
Sagirov Evgeniy
2022-10-12 17:44:04 +03:00
committed by GitHub
parent 062a760242
commit 265ddc426e
3 changed files with 10 additions and 0 deletions

View File

@@ -442,6 +442,9 @@ class StaticCourseTabView(EdxFragmentView):
Displays a static course tab page with a given name
"""
course_key = CourseKey.from_string(course_id)
if course_key.deprecated:
raise Http404
course = get_course_with_access(request.user, 'load', course_key)
tab = CourseTabList.get_tab_by_slug(course.tabs, tab_slug)
if tab is None:
@@ -921,6 +924,8 @@ def dates(request, course_id):
def progress(request, course_id, student_id=None):
""" Display the progress page. """
course_key = CourseKey.from_string(course_id)
if course_key.deprecated:
raise Http404
if course_home_mfe_progress_tab_is_active(course_key) and not request.user.is_staff:
end_of_redirect_url = 'progress' if not student_id else f'progress/{student_id}'

View File

@@ -202,6 +202,8 @@ def use_bulk_ops(view_func):
@wraps(view_func)
def wrapped_view(request, course_id, *args, **kwargs):
course_key = CourseKey.from_string(course_id)
if course_key.deprecated:
raise Http404
with modulestore().bulk_operations(course_key):
return view_func(request, course_key, *args, **kwargs)
return wrapped_view

View File

@@ -118,6 +118,9 @@ def instructor_dashboard_2(request, course_id): # lint-amnesty, pylint: disable
log.error("Unable to find course with course key %s while loading the Instructor Dashboard.", course_id)
return HttpResponseServerError()
if course_key.deprecated:
raise Http404
course = get_course_by_id(course_key, depth=None)
access = {