From 7f80c1afa1f53036e9e6290fb98a7b7334a72bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Thu, 12 Dec 2024 12:11:53 +0100 Subject: [PATCH] fix: adequate course key type in forum v2 (#36022) When checking whether forum v2 is enabled, the course waffle flag argument should be a CourseKey, not a str. --- openedx/core/djangoapps/discussions/config/waffle.py | 4 ++-- .../djangoapps/django_comment_common/comment_client/models.py | 3 ++- .../djangoapps/django_comment_common/comment_client/thread.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openedx/core/djangoapps/discussions/config/waffle.py b/openedx/core/djangoapps/discussions/config/waffle.py index 05fc24eeb3b..eca6fc97085 100644 --- a/openedx/core/djangoapps/discussions/config/waffle.py +++ b/openedx/core/djangoapps/discussions/config/waffle.py @@ -56,7 +56,7 @@ ENABLE_FORUM_V2 = CourseWaffleFlag(f"{WAFFLE_FLAG_NAMESPACE}.enable_forum_v2", __name__) -def is_forum_v2_enabled(course_id): +def is_forum_v2_enabled(course_key): """ Returns whether forum V2 is enabled on the course. This is a 2-step check: @@ -65,7 +65,7 @@ def is_forum_v2_enabled(course_id): """ if is_forum_v2_disabled_globally(): return False - return ENABLE_FORUM_V2.is_enabled(course_id) + return ENABLE_FORUM_V2.is_enabled(course_key) def is_forum_v2_disabled_globally() -> bool: diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/models.py b/openedx/core/djangoapps/django_comment_common/comment_client/models.py index 094475c81fb..9b6c9ca03f3 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/models.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/models.py @@ -74,7 +74,8 @@ def retrieve(self, *args, **kwargs): def _retrieve(self, *args, **kwargs): course_id = self.attributes.get("course_id") or kwargs.get("course_id") if course_id: - use_forumv2 = is_forum_v2_enabled(course_id) + course_key = get_course_key(course_id) + use_forumv2 = is_forum_v2_enabled(course_key) else: use_forumv2, course_id = is_forum_v2_enabled_for_comment(self.id) response = None diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/thread.py b/openedx/core/djangoapps/django_comment_common/comment_client/thread.py index b1f9dbd08d7..ecf420cfae5 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/thread.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/thread.py @@ -174,7 +174,8 @@ def _retrieve(self, *args, **kwargs): request_params = utils.strip_none(request_params) course_id = kwargs.get("course_id") if course_id: - use_forumv2 = is_forum_v2_enabled(course_id) + course_key = utils.get_course_key(course_id) + use_forumv2 = is_forum_v2_enabled(course_key) else: use_forumv2, course_id = is_forum_v2_enabled_for_thread(self.id) if use_forumv2: