Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed fragment to show 404 when discussion tab is clicked #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lms/djangoapps/discussion/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lms/djangoapps/discussion/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
7 changes: 5 additions & 2 deletions lms/djangoapps/discussion/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down