diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 1d26bdcce5b27c1d51da3265c0378efdfa1768a2..1e61ac540ecd81ddef0c503cb2f7aaa7e3616d15 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -92,6 +92,7 @@ from openedx.features.course_experience import ( from openedx.features.course_experience.tests.views.helpers import add_course_mode from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseTestConsentRequired from student.models import CourseEnrollment +from student.roles import CourseStaffRole from student.tests.factories import TEST_PASSWORD, AdminFactory, CourseEnrollmentFactory, UserFactory from util.tests.test_date_utils import fake_pgettext, fake_ugettext from util.url import reload_django_url_config @@ -100,8 +101,10 @@ from xmodule.course_module import COURSE_VISIBILITY_PRIVATE, COURSE_VISIBILITY_P from xmodule.graders import ShowCorrectness from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore + from xmodule.modulestore.tests.django_utils import ( TEST_DATA_MIXED_MODULESTORE, + TEST_DATA_SPLIT_MODULESTORE, CourseUserType, ModuleStoreTestCase, SharedModuleStoreTestCase @@ -3355,6 +3358,8 @@ class TestShowCoursewareMFE(TestCase): @patch.dict('django.conf.settings.FEATURES', {'ENABLE_COURSEWARE_MICROFRONTEND': True}) @ddt.ddt class MFERedirectTests(BaseViewsTestCase): + MODULESTORE = TEST_DATA_SPLIT_MODULESTORE + def _get_urls(self): lms_url = reverse( 'courseware_section', @@ -3379,9 +3384,18 @@ class MFERedirectTests(BaseViewsTestCase): assert self.client.get(lms_url).url == mfe_url def test_staff_no_redirect(self): - # global staff will never be redirected lms_url, mfe_url = self._get_urls() + # course staff will not redirect + course_staff = UserFactory.create(is_staff=False) + CourseStaffRole(self.course_key).add_users(course_staff) + self.client.login(username=course_staff.username, password='test') + + assert self.client.get(lms_url).status_code == 200 + with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, True): + assert self.client.get(lms_url).status_code == 200 + + # global staff will never be redirected self._create_global_staff_user() assert self.client.get(lms_url).status_code == 200 diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index 12595b8d527302677c5fda046750c815ea400bb8..e1f26bfd9c1759728151323c64d82ad2da427a8a 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -191,12 +191,17 @@ class CoursewareIndex(View): """ Redirect to the new courseware micro frontend, unless this is a time limited exam. - - TODO: remove this once exams work in the new MFE. """ - if (not getattr(self.section, 'is_time_limited', False)) \ - and should_redirect_to_courseware_microfrontend(self.course_key) \ - and not request.user.is_staff: + # 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 + url = get_microfrontend_url( self.course_key, self.section.location diff --git a/openedx/core/djangoapps/courseware_api/serializers.py b/openedx/core/djangoapps/courseware_api/serializers.py index 767e26e5d2f3f57e6d114d41c47e67cd4f8a68a0..d47d6c276f500bd70028aaabcdef5e36e0cf42c2 100644 --- a/openedx/core/djangoapps/courseware_api/serializers.py +++ b/openedx/core/djangoapps/courseware_api/serializers.py @@ -107,7 +107,7 @@ class CourseInfoSerializer(serializers.Serializer): # pylint: disable=abstract- tabs = [] for priority, tab in enumerate(get_course_tab_list(course_overview.effective_user, course_overview)): tabs.append({ - 'title': tab.title or tab.get('name'), + 'title': tab.title or tab.get('name', ''), 'slug': tab.tab_id, 'priority': priority, 'type': tab.type,