Skip to content

Commit 94a3c57

Browse files
refactor: remove deprecated sidebar toggles
DEPR ticket: openedx/public-engineering#316
1 parent fd644d4 commit 94a3c57

File tree

4 files changed

+1
-237
lines changed

4 files changed

+1
-237
lines changed

lms/djangoapps/courseware/tests/test_views.py

Lines changed: 1 addition & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from django.test.client import Client
2424
from django.urls import reverse, reverse_lazy
2525
from edx_django_utils.cache.utils import RequestCache
26-
from edx_toggles.toggles.testutils import override_waffle_flag, override_waffle_switch
26+
from edx_toggles.toggles.testutils import override_waffle_flag
2727
from freezegun import freeze_time
2828
from opaque_keys.edx.keys import CourseKey, UsageKey
2929
from pytz import UTC
@@ -71,12 +71,9 @@
7171
from lms.djangoapps.courseware.tests.helpers import MasqueradeMixin, get_expiration_banner_text
7272
from lms.djangoapps.courseware.testutils import RenderXBlockTestMixin
7373
from lms.djangoapps.courseware.toggles import (
74-
COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR,
75-
COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR,
7674
COURSEWARE_MICROFRONTEND_SEARCH_ENABLED,
7775
COURSEWARE_OPTIMIZED_RENDER_XBLOCK,
7876
)
79-
from completion.waffle import ENABLE_COMPLETION_TRACKING_SWITCH
8077
from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient
8178
from lms.djangoapps.courseware.views.views import (
8279
BasePublicVideoXBlockView,
@@ -3238,186 +3235,6 @@ def test_inclusion_date_greater_than_course_start(self, start_date, expected_ena
32383235
self.assertEqual(body, {'enabled': expected_enabled})
32393236

32403237

3241-
class TestCoursewareMFENavigationSidebarTogglesAPI(SharedModuleStoreTestCase):
3242-
"""
3243-
Tests the endpoint to fetch the Courseware Navigation Sidebar waffle flags status.
3244-
"""
3245-
3246-
def setUp(self):
3247-
super().setUp()
3248-
3249-
self.course = CourseFactory.create()
3250-
3251-
self.client = APIClient()
3252-
self.apiUrl = reverse('courseware_navigation_sidebar_toggles_view', kwargs={'course_id': str(self.course.id)})
3253-
3254-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR, active=True)
3255-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR, active=False)
3256-
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=False)
3257-
def test_courseware_mfe_navigation_sidebar_enabled_aux_disabled_completion_track_disabled(self):
3258-
"""
3259-
Getter to check if it is allowed to show the Courseware navigation sidebar to a user
3260-
and auxiliary sidebar doesn't open.
3261-
"""
3262-
response = self.client.get(self.apiUrl, content_type='application/json')
3263-
body = json.loads(response.content.decode('utf-8'))
3264-
3265-
self.assertEqual(response.status_code, 200)
3266-
self.assertEqual(
3267-
body,
3268-
{
3269-
"enable_navigation_sidebar": True,
3270-
"always_open_auxiliary_sidebar": False,
3271-
"enable_completion_tracking": False,
3272-
},
3273-
)
3274-
3275-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR, active=True)
3276-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR, active=False)
3277-
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=True)
3278-
def test_courseware_mfe_navigation_sidebar_enabled_aux_disabled_completion_track_enabled(self):
3279-
"""
3280-
Getter to check if it is allowed to show the Courseware navigation sidebar to a user
3281-
and auxiliary sidebar doesn't open.
3282-
"""
3283-
response = self.client.get(self.apiUrl, content_type='application/json')
3284-
body = json.loads(response.content.decode('utf-8'))
3285-
3286-
self.assertEqual(response.status_code, 200)
3287-
self.assertEqual(
3288-
body,
3289-
{
3290-
"enable_navigation_sidebar": True,
3291-
"always_open_auxiliary_sidebar": False,
3292-
"enable_completion_tracking": True,
3293-
},
3294-
)
3295-
3296-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR, active=True)
3297-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR, active=True)
3298-
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=False)
3299-
def test_courseware_mfe_navigation_sidebar_enabled_aux_enabled_completion_track_disabled(self):
3300-
"""
3301-
Getter to check if it is allowed to show the Courseware navigation sidebar to a user
3302-
and auxiliary sidebar should always open.
3303-
"""
3304-
response = self.client.get(self.apiUrl, content_type='application/json')
3305-
body = json.loads(response.content.decode('utf-8'))
3306-
3307-
self.assertEqual(response.status_code, 200)
3308-
self.assertEqual(
3309-
body,
3310-
{
3311-
"enable_navigation_sidebar": True,
3312-
"always_open_auxiliary_sidebar": True,
3313-
"enable_completion_tracking": False,
3314-
},
3315-
)
3316-
3317-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR, active=True)
3318-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR, active=True)
3319-
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=True)
3320-
def test_courseware_mfe_navigation_sidebar_enabled_aux_enabled_completion_track_enabled(self):
3321-
"""
3322-
Getter to check if it is allowed to show the Courseware navigation sidebar to a user
3323-
and auxiliary sidebar should always open.
3324-
"""
3325-
response = self.client.get(self.apiUrl, content_type='application/json')
3326-
body = json.loads(response.content.decode('utf-8'))
3327-
3328-
self.assertEqual(response.status_code, 200)
3329-
self.assertEqual(
3330-
body,
3331-
{
3332-
"enable_navigation_sidebar": True,
3333-
"always_open_auxiliary_sidebar": True,
3334-
"enable_completion_tracking": True,
3335-
},
3336-
)
3337-
3338-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR, active=False)
3339-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR, active=True)
3340-
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=False)
3341-
def test_courseware_mfe_navigation_sidebar_disabled_aux_enabled_completion_track_disabled(self):
3342-
"""
3343-
Getter to check if the Courseware navigation sidebar shouldn't be shown to a user
3344-
and auxiliary sidebar should always open.
3345-
"""
3346-
response = self.client.get(self.apiUrl, content_type='application/json')
3347-
body = json.loads(response.content.decode('utf-8'))
3348-
3349-
self.assertEqual(response.status_code, 200)
3350-
self.assertEqual(
3351-
body,
3352-
{
3353-
"enable_navigation_sidebar": False,
3354-
"always_open_auxiliary_sidebar": True,
3355-
"enable_completion_tracking": False,
3356-
},
3357-
)
3358-
3359-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR, active=False)
3360-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR, active=True)
3361-
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=True)
3362-
def test_courseware_mfe_navigation_sidebar_disabled_aux_enabled_completion_track_enabled(self):
3363-
"""
3364-
Getter to check if the Courseware navigation sidebar shouldn't be shown to a user
3365-
and auxiliary sidebar should always open.
3366-
"""
3367-
response = self.client.get(self.apiUrl, content_type='application/json')
3368-
body = json.loads(response.content.decode('utf-8'))
3369-
3370-
self.assertEqual(response.status_code, 200)
3371-
self.assertEqual(
3372-
body,
3373-
{
3374-
"enable_navigation_sidebar": False,
3375-
"always_open_auxiliary_sidebar": True,
3376-
"enable_completion_tracking": True,
3377-
},
3378-
)
3379-
3380-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR, active=False)
3381-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR, active=False)
3382-
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=False)
3383-
def test_courseware_mfe_navigation_sidebar_toggles_disabled_completion_track_disabled(self):
3384-
"""
3385-
Getter to check if neither navigation sidebar nor auxiliary sidebar is shown.
3386-
"""
3387-
response = self.client.get(self.apiUrl, content_type='application/json')
3388-
body = json.loads(response.content.decode('utf-8'))
3389-
3390-
self.assertEqual(response.status_code, 200)
3391-
self.assertEqual(
3392-
body,
3393-
{
3394-
"enable_navigation_sidebar": False,
3395-
"always_open_auxiliary_sidebar": False,
3396-
"enable_completion_tracking": False,
3397-
},
3398-
)
3399-
3400-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR, active=False)
3401-
@override_waffle_flag(COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR, active=False)
3402-
@override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, active=True)
3403-
def test_courseware_mfe_navigation_sidebar_toggles_disabled_completion_track_enabled(self):
3404-
"""
3405-
Getter to check if neither navigation sidebar nor auxiliary sidebar is shown.
3406-
"""
3407-
response = self.client.get(self.apiUrl, content_type='application/json')
3408-
body = json.loads(response.content.decode('utf-8'))
3409-
3410-
self.assertEqual(response.status_code, 200)
3411-
self.assertEqual(
3412-
body,
3413-
{
3414-
"enable_navigation_sidebar": False,
3415-
"always_open_auxiliary_sidebar": False,
3416-
"enable_completion_tracking": True,
3417-
},
3418-
)
3419-
3420-
34213238
@ddt.ddt
34223239
class CourseAboutViewTests(ModuleStoreTestCase):
34233240
"""

lms/djangoapps/courseware/toggles.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,33 +83,6 @@
8383
f'{WAFFLE_FLAG_NAMESPACE}.disable_navigation_sidebar_blocks_caching', __name__
8484
)
8585

86-
# .. toggle_name: courseware.enable_navigation_sidebar
87-
# .. toggle_implementation: WaffleFlag
88-
# .. toggle_default: False
89-
# .. toggle_description: Enable navigation sidebar on Learning MFE
90-
# .. toggle_use_cases: opt_out, open_edx
91-
# .. toggle_creation_date: 2024-03-07
92-
# .. toggle_target_removal_date: None
93-
# .. toggle_tickets: FC-0056
94-
COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR = CourseWaffleFlag(
95-
f'{WAFFLE_FLAG_NAMESPACE}.enable_navigation_sidebar', __name__
96-
)
97-
98-
# .. toggle_name: courseware.always_open_auxiliary_sidebar
99-
# .. toggle_implementation: WaffleFlag
100-
# .. toggle_default: True
101-
# .. toggle_description: Waffle flag that determines whether the auxiliary sidebar,
102-
# such as discussion or notification, should automatically expand
103-
# on each course unit page within the Learning MFE, without preserving
104-
# the previous state of the sidebar.
105-
# .. toggle_use_cases: temporary
106-
# .. toggle_creation_date: 2024-04-28
107-
# .. toggle_target_removal_date: 2024-07-28
108-
# .. toggle_tickets: FC-0056
109-
COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR = CourseWaffleFlag(
110-
f'{WAFFLE_FLAG_NAMESPACE}.always_open_auxiliary_sidebar', __name__
111-
)
112-
11386
# .. toggle_name: courseware.mfe_progress_milestones_streak_discount_enabled
11487
# .. toggle_implementation: CourseWaffleFlag
11588
# .. toggle_default: False

lms/djangoapps/courseware/views/views.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@
101101
from lms.djangoapps.courseware.toggles import (
102102
course_is_invitation_only,
103103
courseware_mfe_search_is_enabled,
104-
COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR,
105-
COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR,
106104
)
107-
from completion.waffle import ENABLE_COMPLETION_TRACKING_SWITCH
108105
from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient
109106
from lms.djangoapps.courseware.utils import (
110107
_use_new_financial_assistance_flow,
@@ -2385,21 +2382,3 @@ def courseware_mfe_search_enabled(request, course_id=None):
23852382

23862383
payload = {"enabled": enabled}
23872384
return JsonResponse(payload)
2388-
2389-
2390-
@api_view(['GET'])
2391-
def courseware_mfe_navigation_sidebar_toggles(request, course_id=None):
2392-
"""
2393-
GET endpoint to return navigation sidebar toggles.
2394-
"""
2395-
try:
2396-
course_key = CourseKey.from_string(course_id) if course_id else None
2397-
except InvalidKeyError:
2398-
return JsonResponse({"error": "Invalid course_id"})
2399-
2400-
return JsonResponse({
2401-
"enable_navigation_sidebar": COURSEWARE_MICROFRONTEND_ENABLE_NAVIGATION_SIDEBAR.is_enabled(course_key),
2402-
"always_open_auxiliary_sidebar": COURSEWARE_MICROFRONTEND_ALWAYS_OPEN_AUXILIARY_SIDEBAR.is_enabled(course_key),
2403-
# Add completion tracking status for the sidebar use while a global place for switches is put in place
2404-
"enable_completion_tracking": ENABLE_COMPLETION_TRACKING_SWITCH.is_enabled()
2405-
})

lms/urls.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,11 +759,6 @@
759759
courseware_views.courseware_mfe_search_enabled,
760760
name='courseware_search_enabled_view',
761761
),
762-
re_path(
763-
fr'^courses/{settings.COURSE_ID_PATTERN}/courseware-navigation-sidebar/toggles/$',
764-
courseware_views.courseware_mfe_navigation_sidebar_toggles,
765-
name='courseware_navigation_sidebar_toggles_view',
766-
),
767762
]
768763

769764
urlpatterns += [

0 commit comments

Comments
 (0)