Skip to content
Snippets Groups Projects
Commit 1189580e authored by stvn's avatar stvn
Browse files

Merge PR #24521 cleanup/mfe-flags

* Commits:
  Consolidate MFE redirect logic
parents fb6786d9 9e31d65a
No related branches found
Tags release-2018-12-12-12.20
No related merge requests found
......@@ -37,11 +37,3 @@ REDIRECT_TO_COURSEWARE_MICROFRONTEND = ExperimentWaffleFlag(WAFFLE_FLAG_NAMESPAC
# .. toggle_tickets: TNL-6982
# .. toggle_status: supported
COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'microfrontend_course_team_preview')
def should_redirect_to_courseware_microfrontend(course_key):
return (
settings.FEATURES.get('ENABLE_COURSEWARE_MICROFRONTEND') and
(not course_key.deprecated) and # Old Mongo courses not supported
REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_enabled(course_key)
)
......@@ -74,7 +74,6 @@ from ..permissions import MASQUERADE_AS_STUDENT
from ..toggles import (
COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW,
REDIRECT_TO_COURSEWARE_MICROFRONTEND,
should_redirect_to_courseware_microfrontend,
)
from ..url_helpers import get_microfrontend_url
......@@ -186,16 +185,20 @@ class CoursewareIndex(View):
Redirect to the new courseware micro frontend,
unless this is a time limited exam.
"""
# learners should redirect, if the waffle flag is set
if should_redirect_to_courseware_microfrontend(self.course_key):
# but exams should not redirect to the mfe until they're supported
if getattr(self.section, 'is_time_limited', False):
return
# and staff will not redirect, either
if self.is_staff:
return
# DENY: feature disabled globally
if not settings.FEATURES.get('ENABLE_COURSEWARE_MICROFRONTEND'):
return
# DENY: staff access
if self.is_staff:
return
# DENY: Old Mongo courses, until removed from platform
if self.course_key.deprecated:
return
# DENY: Timed Exams, until supported
if getattr(self.section, 'is_time_limited', False):
return
# ALLOW: when flag set for course
if REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_enabled(self.course_key):
raise Redirect(self.microfrontend_url)
@property
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment