diff --git a/openedx/core/djangoapps/discussions/tests/test_views.py b/openedx/core/djangoapps/discussions/tests/test_views.py index 3935e8ab6d10..b9663af8ed8c 100644 --- a/openedx/core/djangoapps/discussions/tests/test_views.py +++ b/openedx/core/djangoapps/discussions/tests/test_views.py @@ -12,7 +12,6 @@ from django.urls import reverse from edx_toggles.toggles.testutils import override_waffle_flag from lti_consumer.models import CourseAllowPIISharingInLTIFlag -from opaque_keys.edx.keys import CourseKey from rest_framework import status from rest_framework.test import APITestCase @@ -853,7 +852,7 @@ def tearDown(self): IsStaffOrCourseTeam.has_permission = self.original_has_permission super().tearDown() - @patch('openedx.core.djangoapps.discussions.views.update_unit_discussion_state_from_discussion_blocks') + @patch('openedx.core.djangoapps.discussions.views.update_discussions_settings_from_course_task') def test_sync_discussion_topics_staff_user(self, mock_update): """ Test that staff users can sync discussion topics @@ -863,14 +862,9 @@ def test_sync_discussion_topics_staff_user(self, mock_update): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data['status'], 'success') - mock_update.assert_called_once_with( - course_key=CourseKey.from_string(self.course_key_string), - user_id=self.staff_user.id, - force=True, - async_topics=False - ) + mock_update.assert_called_once_with(self.course_key_string) - @patch('openedx.core.djangoapps.discussions.views.update_unit_discussion_state_from_discussion_blocks') + @patch('openedx.core.djangoapps.discussions.views.update_discussions_settings_from_course_task') def test_sync_discussion_topics_course_team(self, mock_update): """ Test that course team members can sync discussion topics diff --git a/openedx/core/djangoapps/discussions/views.py b/openedx/core/djangoapps/discussions/views.py index 07faffb9c1ca..b74d88ca038f 100644 --- a/openedx/core/djangoapps/discussions/views.py +++ b/openedx/core/djangoapps/discussions/views.py @@ -6,7 +6,6 @@ import edx_api_doc_tools as apidocs from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser -from opaque_keys.edx.keys import CourseKey from rest_framework.exceptions import ValidationError from rest_framework.permissions import IsAuthenticated from rest_framework.request import Request @@ -21,7 +20,7 @@ from .models import AVAILABLE_PROVIDER_MAP, DiscussionsConfiguration, Features, Provider from .permissions import IsStaffOrCourseTeam, check_course_permissions from .serializers import DiscussionsConfigurationSerializer, DiscussionsProvidersSerializer -from .tasks import update_unit_discussion_state_from_discussion_blocks +from .tasks import update_discussions_settings_from_course_task class DiscussionsConfigurationSettingsView(APIView): @@ -272,13 +271,7 @@ def post(self, request, course_key_string): Returns: Response: modified course configuration data """ - update_unit_discussion_state_from_discussion_blocks( - course_key=CourseKey.from_string(course_key_string), - user_id=request.user.id, - force=True, - async_topics=False - ) - + update_discussions_settings_from_course_task(course_key_string) return Response({ "status": "success", "message": "Discussion topics synced successfully."