Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions openedx/core/djangoapps/discussions/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 2 additions & 9 deletions openedx/core/djangoapps/discussions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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."
Expand Down
Loading