From fae6ece4272436079c85bcc525042afc1f44e02b Mon Sep 17 00:00:00 2001 From: Ahtisham Shahid Date: Tue, 25 Apr 2023 12:44:26 +0500 Subject: [PATCH] fix: added check for empty list in discussions settings task (#32105) * fix: added check for empty list in discussions settings task --- openedx/core/djangoapps/discussions/tasks.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/discussions/tasks.py b/openedx/core/djangoapps/discussions/tasks.py index 766644f5af..fae7f21e41 100644 --- a/openedx/core/djangoapps/discussions/tasks.py +++ b/openedx/core/djangoapps/discussions/tasks.py @@ -113,8 +113,14 @@ def get_discussable_units(course, enable_graded_units, discussable_units=None): unit.discussion_enabled = False store.update_item(unit, unit.published_by, emit_signals=False) continue - if discussable_units and (str(unit.location) not in discussable_units): + # check if discussable_units is type of list and discussable_units is empty + # it means if discussable_units is empty then we should not create any topic + if isinstance(discussable_units, list) and not discussable_units: continue + + if isinstance(discussable_units, list) and (str(unit.location) not in discussable_units): + continue + yield DiscussionTopicContext( usage_key=unit.location, title=unit.display_name, @@ -191,6 +197,7 @@ def update_unit_discussion_state_from_discussion_blocks(course_key: CourseKey, u course = store.get_course(course_key) provider = course.discussions_settings.get('provider', None) # Only migrate to the new discussion provider if the current provider is the legacy provider. + log.info(f"Current provider for {course_key} is {provider}") if provider is not None and provider != Provider.LEGACY and not force: return