Skip to content

Commit

Permalink
feat: add a feature flag to disable dates tab for all courses
Browse files Browse the repository at this point in the history
(cherry picked from commit 88bb2a4)
  • Loading branch information
Cup0fCoffee authored and 0x29a committed Jun 26, 2024
1 parent 6498393 commit 049e001
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lms/djangoapps/courseware/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ def link_func(course, _reverse_func):
tab_dict['link_func'] = link_func
super().__init__(tab_dict)

@classmethod
def is_enabled(cls, course, user=None):
if settings.FEATURES.get('DISABLE_DATES_TAB'):
return False
return super().is_enabled(course, user)


def get_course_tab_list(user, course):
"""
Expand Down
13 changes: 13 additions & 0 deletions lms/djangoapps/courseware/tests/test_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,3 +885,16 @@ def test_singular_dates_tab(self):
if tab.type == 'dates':
num_dates_tabs += 1
assert num_dates_tabs == 1

def test_dates_tab_is_enabled_by_default(self):
"""Test dates tab is enabled by default."""
tab = DatesTab({'type': DatesTab.type, 'name': 'dates'})
user = self.create_mock_user()
assert self.is_tab_enabled(tab, self.course, user)

@patch.dict("django.conf.settings.FEATURES", {"DISABLE_DATES_TAB": True})
def test_dates_tab_disabled_by_feature_flag(self):
"""Test dates tab is disabled by the feature flag."""
tab = DatesTab({'type': DatesTab.type, 'name': 'dates'})
user = self.create_mock_user()
assert not self.is_tab_enabled(tab, self.course, user)
9 changes: 9 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,15 @@
# .. toggle_target_removal_date: None
# .. toggle_tickets: 'https://github.com/open-craft/edx-platform/pull/632/files'
'ENABLE_TEACHING_ASSISTANT_ROLE': False,

# .. toggle_name: FEATURES['DISABLE_DATES_TAB']
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Disables dates tab for all courses.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2024-04-15
# .. toggle_tickets: https://github.com/openedx/edx-platform/pull/34511
'DISABLE_DATES_TAB': False,
}

# Specifies extra XBlock fields that should available when requested via the Course Blocks API
Expand Down

0 comments on commit 049e001

Please sign in to comment.