Skip to content

Commit

Permalink
feat: [AXIMST-629] new waffle flag for displaying discussions tab in …
Browse files Browse the repository at this point in the history
…learning MFE by default
  • Loading branch information
NiedielnitsevIvan committed Mar 14, 2024
1 parent bb61ce2 commit cacdec9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
20 changes: 20 additions & 0 deletions lms/djangoapps/courseware/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@
f'{WAFFLE_FLAG_NAMESPACE}.disable_navigation_sidebar', __name__
)

# .. toggle_name: courseware.disable_default_open_discussion_sidebar
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Disable opening the discussion sidebar by default on Learning MFE.
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2024-03-13
# .. toggle_target_removal_date: None
# .. toggle_tickets: AXIMST-629
# .. toggle_warning: None.
COURSEWARE_MICROFRONTEND_DISCUSSION_SIDEBAR_OPEN_DISABLED = CourseWaffleFlag(
f'{WAFFLE_FLAG_NAMESPACE}.disable_default_open_discussion_sidebar', __name__
)

# .. toggle_name: courseware.mfe_progress_milestones_streak_discount_enabled
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
Expand Down Expand Up @@ -206,3 +219,10 @@ def courseware_mfe_sidebar_is_disabled(course_key=None):
Return whether the courseware.disable_navigation_sidebar flag is on.
"""
return COURSEWARE_MICROFRONTEND_SIDEBAR_DISABLED.is_enabled(course_key)


def courseware_mfe_discussion_sidebar_open_is_disabled(course_key=None):
"""
Return whether the courseware.disable_default_open_discussion_sidebar flag is on.
"""
return COURSEWARE_MICROFRONTEND_DISCUSSION_SIDEBAR_OPEN_DISABLED.is_enabled(course_key)
15 changes: 14 additions & 1 deletion lms/djangoapps/courseware/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@
from lms.djangoapps.courseware.permissions import MASQUERADE_AS_STUDENT, VIEW_COURSE_HOME, VIEW_COURSEWARE
from lms.djangoapps.courseware.toggles import (
course_is_invitation_only,
courseware_mfe_discussion_sidebar_open_is_disabled,
courseware_mfe_search_is_enabled,
courseware_mfe_sidebar_is_disabled
courseware_mfe_sidebar_is_disabled,
)
from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient
from lms.djangoapps.courseware.utils import (
Expand Down Expand Up @@ -2285,3 +2286,15 @@ def courseware_mfe_sidebar_enabled(request, course_id=None):
return JsonResponse({
"enabled": not courseware_mfe_sidebar_is_disabled(course_key)
})


@api_view(['GET'])
def courseware_mfe_discussion_sidebar_open_is_enabled(request, course_id=None):
"""
Simple GET endpoint to expose whether the course may open discussion sidebar by default.
"""
course_key = CourseKey.from_string(course_id) if course_id else None

return JsonResponse({
"enabled": not courseware_mfe_discussion_sidebar_open_is_disabled(course_key)
})
5 changes: 5 additions & 0 deletions lms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,11 @@
courseware_views.courseware_mfe_sidebar_enabled,
name='courseware_sidebar_enabled_view',
),
re_path(
fr'^courses/{settings.COURSE_ID_PATTERN}/discussion-sidebar/enabled/$',
courseware_views.courseware_mfe_discussion_sidebar_open_is_enabled,
name='discussion_sidebar_enabled_view',
),
]

urlpatterns += [
Expand Down

0 comments on commit cacdec9

Please sign in to comment.