Addressed review feedback

This commit is contained in:
Dave St.Germain
2020-03-06 16:12:07 -05:00
parent 28f33e1667
commit 49c5d5194b
3 changed files with 26 additions and 7 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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,