diff --git a/lms/djangoapps/course_home_api/dates/views.py b/lms/djangoapps/course_home_api/dates/views.py index f7f7fb3209..3ca59b6bdc 100644 --- a/lms/djangoapps/course_home_api/dates/views.py +++ b/lms/djangoapps/course_home_api/dates/views.py @@ -2,7 +2,6 @@ Dates Tab Views """ -from django.http.response import Http404 from edx_django_utils import monitoring as monitoring_utils from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser @@ -14,7 +13,6 @@ from rest_framework.response import Response from common.djangoapps.student.models import CourseEnrollment from lms.djangoapps.course_goals.models import UserActivity from lms.djangoapps.course_home_api.dates.serializers import DatesTabSerializer -from lms.djangoapps.course_home_api.toggles import course_home_legacy_is_active from lms.djangoapps.courseware.access import has_access from lms.djangoapps.courseware.context_processor import user_timezone_locale_prefs from lms.djangoapps.courseware.courses import get_course_date_blocks, get_course_with_access @@ -76,9 +74,6 @@ class DatesTabView(RetrieveAPIView): course_key_string = kwargs.get('course_key_string') course_key = CourseKey.from_string(course_key_string) - if course_home_legacy_is_active(course_key): - raise Http404 - # Enable NR tracing for this view based on course monitoring_utils.set_custom_attribute('course_id', course_key_string) monitoring_utils.set_custom_attribute('user_id', request.user.id) diff --git a/lms/djangoapps/course_home_api/outline/views.py b/lms/djangoapps/course_home_api/outline/views.py index f17d9b0f46..863f9c07dc 100644 --- a/lms/djangoapps/course_home_api/outline/views.py +++ b/lms/djangoapps/course_home_api/outline/views.py @@ -198,10 +198,7 @@ class OutlineTabView(RetrieveAPIView): user_timezone_locale = user_timezone_locale_prefs(request) user_timezone = user_timezone_locale['user_timezone'] - if course_home_legacy_is_active(course.id): - dates_tab_link = request.build_absolute_uri(reverse('dates', args=[course.id])) - else: - dates_tab_link = get_learning_mfe_home_url(course_key=course.id, url_fragment='dates') + dates_tab_link = get_learning_mfe_home_url(course_key=course.id, url_fragment='dates') # Set all of the defaults access_expiration = None diff --git a/lms/djangoapps/courseware/tabs.py b/lms/djangoapps/courseware/tabs.py index f599e9b3df..911819e855 100644 --- a/lms/djangoapps/courseware/tabs.py +++ b/lms/djangoapps/courseware/tabs.py @@ -334,11 +334,8 @@ class DatesTab(EnrolledTab): view_name = "dates" def __init__(self, tab_dict): - def link_func(course, reverse_func): - if course_home_legacy_is_active(course.id): - return reverse_func(self.view_name, args=[str(course.id)]) - else: - return get_learning_mfe_home_url(course_key=course.id, url_fragment=self.view_name) + def link_func(course, _reverse_func): + return get_learning_mfe_home_url(course_key=course.id, url_fragment='dates') tab_dict['link_func'] = link_func super().__init__(tab_dict) diff --git a/lms/djangoapps/courseware/tests/test_date_summary.py b/lms/djangoapps/courseware/tests/test_date_summary.py index 2ea337d639..3e914168fd 100644 --- a/lms/djangoapps/courseware/tests/test_date_summary.py +++ b/lms/djangoapps/courseware/tests/test_date_summary.py @@ -724,33 +724,25 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase): assert block.relative_datestring == expected_date_string @ddt.data( - ('info', True), - ('info', False), - ('openedx.course_experience.course_home', True), - ('openedx.course_experience.course_home', False), + 'info', + 'openedx.course_experience.course_home', ) - @ddt.unpack @override_waffle_flag(DISABLE_UNIFIED_COURSE_TAB_FLAG, active=False) @override_waffle_flag(RELATIVE_DATES_FLAG, active=True) - def test_dates_tab_link_render(self, url_name, legacy_active): + def test_dates_tab_link_render(self, url_name): """ The dates tab link should only show for enrolled or staff users """ course = create_course_run() html_elements = [ 'class="dates-tab-link"', 'View all course dates', + f'/course/{course.id}/dates', ] - # The url should change based on the mfe being active. - if legacy_active: - html_elements.append('/courses/' + str(course.id) + '/dates') - else: - html_elements.append('/course/' + str(course.id) + '/dates') url = reverse(url_name, args=(course.id,)) def assert_html_elements(assert_function, user): self.client.login(username=user.username, password=TEST_PASSWORD) - with override_waffle_flag(COURSE_HOME_USE_LEGACY_FRONTEND, active=legacy_active): - response = self.client.get(url, follow=True) - if legacy_active or user.is_staff: + response = self.client.get(url, follow=True) + if user.is_staff: for html in html_elements: assert_function(response, html) else: diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 65c2539277..fe595289f4 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -8,7 +8,7 @@ import itertools import json import re from datetime import datetime, timedelta -from unittest.mock import MagicMock, PropertyMock, call, create_autospec, patch +from unittest.mock import MagicMock, PropertyMock, create_autospec, patch from urllib.parse import urlencode from uuid import uuid4 @@ -30,7 +30,7 @@ from freezegun import freeze_time from markupsafe import escape from milestones.tests.utils import MilestonesTestCaseMixin from opaque_keys.edx.keys import CourseKey, UsageKey -from pytz import UTC, utc +from pytz import UTC from web_fragments.fragment import Fragment from xblock.core import XBlock from xblock.fields import Scope, String @@ -97,7 +97,6 @@ from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateCli from lms.djangoapps.grades.config.waffle import ASSUME_ZERO_GRADE_IF_ABSENT from lms.djangoapps.grades.config.waffle import waffle_switch as grades_waffle_switch from lms.djangoapps.instructor.access import allow_access -from lms.djangoapps.verify_student.models import VerificationDeadline from lms.djangoapps.verify_student.services import IDVerificationService from openedx.core.djangoapps.catalog.tests.factories import CourseFactory as CatalogCourseFactory from openedx.core.djangoapps.catalog.tests.factories import CourseRunFactory, ProgramFactory @@ -115,7 +114,6 @@ from openedx.features.course_experience import ( COURSE_ENABLE_UNENROLLED_ACCESS_FLAG, DISABLE_COURSE_OUTLINE_PAGE_FLAG, DISABLE_UNIFIED_COURSE_TAB_FLAG, - RELATIVE_DATES_FLAG ) from openedx.features.course_experience.tests.views.helpers import add_course_mode from openedx.features.course_experience.url_helpers import ( @@ -3496,146 +3494,17 @@ class AccessUtilsTestCase(ModuleStoreTestCase): assert bool(check_course_open_for_learner(staff_user, course)) == expected_value -@ddt.ddt -@override_waffle_flag(COURSE_HOME_USE_LEGACY_FRONTEND, active=True) -class DatesTabTestCase(ModuleStoreTestCase): +class DatesTabTestCase(TestCase): """ - Ensure that the dates page renders with the correct data for both a verified and audit learner + Ensure that the legacy dates view redirects appropriately (it no longer exists). """ - def setUp(self): - super().setUp() - - now = datetime.now(utc) - self.course = CourseFactory.create(start=now + timedelta(days=-1), self_paced=True) - self.course.end = now + timedelta(days=3) - - ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1)) - CourseModeFactory(course_id=self.course.id, mode_slug=CourseMode.AUDIT) - CourseModeFactory( - course_id=self.course.id, - mode_slug=CourseMode.VERIFIED, - expiration_datetime=now + timedelta(days=1) - ) - VerificationDeadline.objects.create( - course_key=self.course.id, - deadline=now + timedelta(days=2) - ) - - self.user = UserFactory() - self.client.login(username=self.user.username, password=TEST_PASSWORD) - ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2017, 1, 1)) - - def _get_response(self, course): - """ Returns the HTML for the dates page """ - return self.client.get(reverse('dates', args=[str(course.id)])) - - def test_tab_redirects_if_not_logged_in(self): - self.client.logout() - response = self._get_response(self.course) - assert response.status_code == 302 - assert '/login?next=/courses/' in response.url - - def test_tab_redirects_if_not_enrolled_and_not_staff(self): - response = self._get_response(self.course) - assert response.status_code == 302 - # Beginning of redirect URL - assert '/courses/' in response.url - # End of redirect URL - assert '/course/' in response.url - - # Now check staff users can see - self.user.is_staff = True - self.user.save() - response = self._get_response(self.course) - assert response.status_code == 200 - - # Enrolled users can also see - self.client.logout() - enrolled_user = UserFactory() - CourseEnrollmentFactory(course_id=self.course.id, user=enrolled_user, mode=CourseMode.VERIFIED) - self.client.login(username=enrolled_user.username, password=TEST_PASSWORD) - response = self._get_response(self.course) - assert response.status_code == 200 - - @override_waffle_flag(RELATIVE_DATES_FLAG, active=True) - @patch('edx_django_utils.monitoring.set_custom_attribute') - def test_defaults(self, mock_set_custom_attribute): - enrollment = CourseEnrollmentFactory(course_id=self.course.id, user=self.user, mode=CourseMode.VERIFIED) - now = datetime.now(utc) - with self.store.bulk_operations(self.course.id): - section = ItemFactory.create(category='chapter', parent_location=self.course.location) - subsection = ItemFactory.create( - category='sequential', - display_name='Released', - parent_location=section.location, - start=now - timedelta(days=1), - due=now + timedelta(days=1), # Setting this to tomorrow so it'll show the 'Due Next' pill - graded=True, - format='Homework', - ) - vertical = ItemFactory.create(category='vertical', parent_location=subsection.location) - ItemFactory.create(category='problem', parent_location=vertical.location, has_score=True) - - response = self._get_response(self.course) - self.assertContains(response, subsection.display_name) - # Show the Verification Deadline for verified only - self.assertContains(response, 'Verification Deadline') - # Make sure pill exists for today's date - self.assertContains(response, '