From 5c0942481ce292a90f86259bd223d66e7ceffe9f Mon Sep 17 00:00:00 2001 From: Ahtisham Shahid Date: Mon, 12 Aug 2024 12:53:55 +0500 Subject: [PATCH] fix: update course discussion config before course load (#35219) fix: update course discussion config before course load fix: updated unit tests fix: resolved content issue in renamed notification --- cms/djangoapps/contentstore/views/course.py | 5 +++++ cms/djangoapps/contentstore/views/tests/test_course_index.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 9f6cfb7c430e..4647e4fdcca7 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -58,6 +58,7 @@ from common.djangoapps.util.string_utils import _has_non_ascii_characters from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from openedx.core.djangoapps.credit.tasks import update_credit_course_requirements +from openedx.core.djangoapps.discussions.tasks import update_discussions_settings_from_course from openedx.core.djangoapps.models.course_details import CourseDetails from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangolib.js_utils import dump_js_escaped_json @@ -302,6 +303,10 @@ def course_handler(request, course_key_string=None): else: return HttpResponseBadRequest() elif request.method == 'GET': # assume html + # Update course discussion settings, sometimes the course discussion settings are not updated + # when the course is created, so we need to update them here. + course_key = CourseKey.from_string(course_key_string) + update_discussions_settings_from_course(course_key) if course_key_string is None: return redirect(reverse('home')) else: diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index c3dcfe5305b7..30e02214a1a8 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -717,8 +717,8 @@ def test_number_of_calls_to_db(self): """ Test to check number of queries made to mysql and mongo """ - with self.assertNumQueries(29, table_ignorelist=WAFFLE_TABLES): - with check_mongo_calls(3): + with self.assertNumQueries(32, table_ignorelist=WAFFLE_TABLES): + with check_mongo_calls(5): self.client.get_html(reverse_course_url('course_handler', self.course.id))