diff --git a/lms/djangoapps/discussion/plugins.py b/lms/djangoapps/discussion/plugins.py index 6574778a4831..7423877f7065 100644 --- a/lms/djangoapps/discussion/plugins.py +++ b/lms/djangoapps/discussion/plugins.py @@ -8,7 +8,7 @@ import lms.djangoapps.discussion.django_comment_client.utils as utils from lms.djangoapps.courseware.tabs import EnrolledTab -from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE +from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE, DISCUSSION_DISABLED from openedx.core.djangoapps.discussions.url_helpers import get_discussions_mfe_url from openedx.features.lti_course_tab.tab import DiscussionLtiCourseTab from xmodule.tabs import TabFragmentViewMixin # lint-amnesty, pylint: disable=wrong-import-order @@ -45,6 +45,8 @@ def link_func(course, reverse_func): @classmethod def is_enabled(cls, course, user=None): + if DISCUSSION_DISABLED.is_enabled(course.id): + return False if not super().is_enabled(course, user): return False # Disable the regular discussion tab if LTI-based external Discussion forum is enabled diff --git a/lms/djangoapps/discussion/toggles.py b/lms/djangoapps/discussion/toggles.py index 31a7f5ac16e9..0f7159bf71e9 100644 --- a/lms/djangoapps/discussion/toggles.py +++ b/lms/djangoapps/discussion/toggles.py @@ -13,3 +13,4 @@ # .. toggle_creation_date: 2021-11-05 # .. toggle_target_removal_date: 2022-03-05 ENABLE_DISCUSSIONS_MFE = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'enable_discussions_mfe', __name__) +DISCUSSION_DISABLED = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'disable_discussion_tab', __name__) diff --git a/lms/djangoapps/discussion/views.py b/lms/djangoapps/discussion/views.py index 824d71925670..3dedc5038a4a 100644 --- a/lms/djangoapps/discussion/views.py +++ b/lms/djangoapps/discussion/views.py @@ -45,7 +45,7 @@ strip_none, ) from lms.djangoapps.discussion.exceptions import TeamDiscussionHiddenFromUserException -from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE +from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE, DISCUSSION_DISABLED from lms.djangoapps.experiments.utils import get_experiment_user_metadata_context from lms.djangoapps.teams import api as team_api from openedx.core.djangoapps.discussions.url_helpers import get_discussions_mfe_url @@ -762,7 +762,10 @@ def render_to_fragment( # lint-amnesty, pylint: disable=arguments-differ context.update({ 'course_expiration_fragment': course_expiration_fragment, }) - if profile_page_context: + + if DISCUSSION_DISABLED.is_enabled(course_key): + raise Http404 + elif profile_page_context: # EDUCATOR-2119: styles are hard to reconcile if the profile page isn't also a fragment html = render_to_string('discussion/discussion_profile_page.html', profile_page_context) else: