Skip to content

Commit

Permalink
fix: adequate course key type in forum v2
Browse files Browse the repository at this point in the history
When checking whether forum v2 is enabled, the course waffle flag
argument should be a CourseKey, not a str.
  • Loading branch information
regisb committed Dec 12, 2024
1 parent c6dbb16 commit badd406
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions openedx/core/djangoapps/discussions/config/waffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit badd406

Please sign in to comment.