Skip to content

Commit

Permalink
feat: add flag for showing/hiding new discussion sidebar view on cour…
Browse files Browse the repository at this point in the history
…se home page. (openedx#34561)

Co-authored-by: Saad Yousaf <[email protected]>
  • Loading branch information
saadyousafarbi and Saad Yousaf authored Apr 29, 2024
1 parent 70c5087 commit 45cd459
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ class CourseHomeMetadataSerializer(VerifiedModeSerializer):
user_timezone = serializers.CharField()
can_view_certificate = serializers.BooleanField()
course_modes = CourseModeSerrializer(many=True)
is_new_discussion_sidebar_view_enabled = serializers.BooleanField()
2 changes: 2 additions & 0 deletions lms/djangoapps/course_home_api/course_metadata/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser
from lms.djangoapps.certificates.api import certificates_viewable_for_course
from lms.djangoapps.course_home_api.toggles import new_discussion_sidebar_view_is_enabled
from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser
from openedx.core.djangoapps.courseware_api.utils import get_celebrations_dict

Expand Down Expand Up @@ -137,6 +138,7 @@ def get(self, request, *args, **kwargs):
'user_timezone': user_timezone,
'can_view_certificate': certificates_viewable_for_course(course),
'course_modes': course_modes,
'is_new_discussion_sidebar_view_enabled': new_discussion_sidebar_view_is_enabled(course_key),
}
context = self.get_serializer_context()
context['course'] = course
Expand Down
22 changes: 22 additions & 0 deletions lms/djangoapps/course_home_api/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@
)


# Waffle flag to enable new discussion sidebar view on course home page
#
# .. toggle_name: course_home.new_discussion_sidebar_view
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
# .. toggle_description: This toggle controls the user interface behavior of the discussion sidebar on course home page.
# .. toggle_use_cases: open_edx, temporary
# .. toggle_creation_date: 2024-04-22
# .. toggle_target_removal_date: None
# .. toggle_tickets: INF-1338
COURSE_HOME_NEW_DISCUSSION_SIDEBAR_VIEW = CourseWaffleFlag(
f'{WAFFLE_FLAG_NAMESPACE}.new_discussion_sidebar_view', __name__
)


def course_home_mfe_progress_tab_is_active(course_key):
# Avoiding a circular dependency
from .models import DisableProgressPageStackedConfig
Expand All @@ -29,3 +44,10 @@ def course_home_mfe_progress_tab_is_active(course_key):
COURSE_HOME_MICROFRONTEND_PROGRESS_TAB.is_enabled(course_key) and
not DisableProgressPageStackedConfig.current(course_key=course_key).disabled
)


def new_discussion_sidebar_view_is_enabled(course_key):
"""
Returns True if the new discussion sidebar view is enabled for the given course.
"""
return COURSE_HOME_NEW_DISCUSSION_SIDEBAR_VIEW.is_enabled(course_key)

0 comments on commit 45cd459

Please sign in to comment.