Skip to content

Commit

Permalink
feat: [FC-0056] add waffle flag for opening discussions/notifications…
Browse files Browse the repository at this point in the history
… by default
  • Loading branch information
NiedielnitsevIvan authored and GlugovGrGlib committed May 2, 2024
1 parent 2ce25b3 commit 15c43b0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
22 changes: 22 additions & 0 deletions lms/djangoapps/courseware/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@
f'{WAFFLE_FLAG_NAMESPACE}.disable_navigation_sidebar_blocks_caching', __name__
)

# .. toggle_name: courseware.show_default_right_sidebar
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: If waffle flag disabled
# Discussions or Notifications sidebar shouldn't be displayed at all on Learning MFE.
# If waffle flag enabled - Discussions opens always on the pages with discussions,
# if user is in Audit and course has verified mode - show Notifications.# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2024-04-28
# .. toggle_target_removal_date: None
# .. toggle_tickets: FC-0056
# .. toggle_warning: None.
COURSEWARE_SHOW_DEFAULT_RIGHT_SIDEBAR = CourseWaffleFlag(
f'{WAFFLE_FLAG_NAMESPACE}.show_default_right_sidebar', __name__
)

# .. toggle_name: courseware.mfe_progress_milestones_streak_discount_enabled
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
Expand Down Expand Up @@ -192,3 +207,10 @@ def courseware_disable_navigation_sidebar_blocks_caching(course_key=None):
Return whether the courseware.disable_navigation_sidebar_blocks_caching flag is on.
"""
return COURSEWARE_MICROFRONTEND_NAVIGATION_SIDEBAR_BLOCKS_DISABLE_CACHING.is_enabled(course_key)


def courseware_show_default_right_sidebar_is_enabled(course_key=None):
"""
Return whether the courseware.show_default_right_sidebar flag is on.
"""
return COURSEWARE_SHOW_DEFAULT_RIGHT_SIDEBAR.is_enabled(course_key)
22 changes: 21 additions & 1 deletion lms/djangoapps/courseware/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@
from lms.djangoapps.courseware.model_data import FieldDataCache
from lms.djangoapps.courseware.models import BaseStudentModuleHistory, StudentModule
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_search_is_enabled
from lms.djangoapps.courseware.toggles import (
course_is_invitation_only,
courseware_mfe_search_is_enabled,
courseware_show_default_right_sidebar_is_enabled,
)
from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient
from lms.djangoapps.courseware.utils import (
_use_new_financial_assistance_flow,
Expand Down Expand Up @@ -2282,3 +2286,19 @@ def courseware_mfe_search_enabled(request, course_id=None):

payload = {"enabled": courseware_mfe_search_is_enabled(course_key) if enabled else False}
return JsonResponse(payload)


@api_view(['GET'])
def courseware_mfe_show_default_right_sidebar_is_enabled(request, course_id=None):
"""
Simple GET endpoint to expose whether the course may open discussion sidebar by default.
"""
try:
course_key = CourseKey.from_string(course_id) if course_id else None
except InvalidKeyError:
return JsonResponse({"error": "Invalid course_id"})

return JsonResponse({
"enabled": courseware_show_default_right_sidebar_is_enabled(course_key)
})

5 changes: 5 additions & 0 deletions lms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,11 @@
courseware_views.courseware_mfe_search_enabled,
name='courseware_search_enabled_view',
),
re_path(
fr'^courses/{settings.COURSE_ID_PATTERN}/discussion-sidebar/enabled/$',
courseware_views.courseware_mfe_show_default_right_sidebar_is_enabled,
name='show_default_right_sidebar_enabled_view',
),
]

urlpatterns += [
Expand Down

0 comments on commit 15c43b0

Please sign in to comment.