Skip to content

Commit c080f96

Browse files
fix: Updates task in topics sync API (#36853)
fix: Updates task in topics sync API
1 parent 755f757 commit c080f96

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

openedx/core/djangoapps/discussions/tests/test_views.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from django.urls import reverse
1313
from edx_toggles.toggles.testutils import override_waffle_flag
1414
from lti_consumer.models import CourseAllowPIISharingInLTIFlag
15-
from opaque_keys.edx.keys import CourseKey
1615
from rest_framework import status
1716
from rest_framework.test import APITestCase
1817

@@ -853,7 +852,7 @@ def tearDown(self):
853852
IsStaffOrCourseTeam.has_permission = self.original_has_permission
854853
super().tearDown()
855854

856-
@patch('openedx.core.djangoapps.discussions.views.update_unit_discussion_state_from_discussion_blocks')
855+
@patch('openedx.core.djangoapps.discussions.views.update_discussions_settings_from_course_task')
857856
def test_sync_discussion_topics_staff_user(self, mock_update):
858857
"""
859858
Test that staff users can sync discussion topics
@@ -863,14 +862,9 @@ def test_sync_discussion_topics_staff_user(self, mock_update):
863862

864863
self.assertEqual(response.status_code, status.HTTP_200_OK)
865864
self.assertEqual(response.data['status'], 'success')
866-
mock_update.assert_called_once_with(
867-
course_key=CourseKey.from_string(self.course_key_string),
868-
user_id=self.staff_user.id,
869-
force=True,
870-
async_topics=False
871-
)
865+
mock_update.assert_called_once_with(self.course_key_string)
872866

873-
@patch('openedx.core.djangoapps.discussions.views.update_unit_discussion_state_from_discussion_blocks')
867+
@patch('openedx.core.djangoapps.discussions.views.update_discussions_settings_from_course_task')
874868
def test_sync_discussion_topics_course_team(self, mock_update):
875869
"""
876870
Test that course team members can sync discussion topics

openedx/core/djangoapps/discussions/views.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import edx_api_doc_tools as apidocs
77
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
88
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser
9-
from opaque_keys.edx.keys import CourseKey
109
from rest_framework.exceptions import ValidationError
1110
from rest_framework.permissions import IsAuthenticated
1211
from rest_framework.request import Request
@@ -21,7 +20,7 @@
2120
from .models import AVAILABLE_PROVIDER_MAP, DiscussionsConfiguration, Features, Provider
2221
from .permissions import IsStaffOrCourseTeam, check_course_permissions
2322
from .serializers import DiscussionsConfigurationSerializer, DiscussionsProvidersSerializer
24-
from .tasks import update_unit_discussion_state_from_discussion_blocks
23+
from .tasks import update_discussions_settings_from_course_task
2524

2625

2726
class DiscussionsConfigurationSettingsView(APIView):
@@ -272,13 +271,7 @@ def post(self, request, course_key_string):
272271
Returns:
273272
Response: modified course configuration data
274273
"""
275-
update_unit_discussion_state_from_discussion_blocks(
276-
course_key=CourseKey.from_string(course_key_string),
277-
user_id=request.user.id,
278-
force=True,
279-
async_topics=False
280-
)
281-
274+
update_discussions_settings_from_course_task(course_key_string)
282275
return Response({
283276
"status": "success",
284277
"message": "Discussion topics synced successfully."

0 commit comments

Comments
 (0)