diff --git a/lms/djangoapps/discussion_api/tests/test_views.py b/lms/djangoapps/discussion_api/tests/test_views.py index 1c4a8bdddc..6a50baaa08 100644 --- a/lms/djangoapps/discussion_api/tests/test_views.py +++ b/lms/djangoapps/discussion_api/tests/test_views.py @@ -236,6 +236,7 @@ class RetireViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): """ pass + @httpretty.activate @mock.patch('django.conf.settings.USERNAME_REPLACEMENT_WORKER', 'test_replace_username_service_worker') @mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True}) @@ -312,6 +313,7 @@ class ReplaceUsernameViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): """ pass + @ddt.ddt @mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True}) class CourseTopicsViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase): diff --git a/lms/djangoapps/discussion_api/views.py b/lms/djangoapps/discussion_api/views.py index d43ab98f3e..7af8820071 100644 --- a/lms/djangoapps/discussion_api/views.py +++ b/lms/djangoapps/discussion_api/views.py @@ -588,6 +588,7 @@ class RetireUserView(APIView): return Response(status=status.HTTP_204_NO_CONTENT) + class ReplaceUsernameView(APIView): """ A request from the settings.USERNAME_REPLACEMENT_WORKER user can replace @@ -631,15 +632,6 @@ class ReplaceUsernameView(APIView): return Response(status=status.HTTP_204_NO_CONTENT) - - - - - - - - - class CourseDiscussionSettingsAPIView(DeveloperErrorViewMixin, APIView): """ **Use Cases** diff --git a/lms/lib/comment_client/user.py b/lms/lib/comment_client/user.py index d854d2848b..a007bd1d75 100644 --- a/lms/lib/comment_client/user.py +++ b/lms/lib/comment_client/user.py @@ -225,6 +225,7 @@ def _url_for_retire(user_id): """ return "{prefix}/users/{user_id}/retire".format(prefix=settings.PREFIX, user_id=user_id) + def _url_for_username_replacement(user_id): """ Returns cs_comments_servuce url endpoint to replace the username of a user diff --git a/openedx/core/djangoapps/user_api/accounts/permissions.py b/openedx/core/djangoapps/user_api/accounts/permissions.py index 84d4155011..b402478f6a 100644 --- a/openedx/core/djangoapps/user_api/accounts/permissions.py +++ b/openedx/core/djangoapps/user_api/accounts/permissions.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals from django.conf import settings from rest_framework import permissions + class CanDeactivateUser(permissions.BasePermission): """ Grants access to AccountDeactivationView if the requesting user is a superuser @@ -24,6 +25,7 @@ class CanRetireUser(permissions.BasePermission): def has_permission(self, request, view): return request.user.has_perm('accounts.can_retire_user') + class CanReplaceUsername(permissions.BasePermission): """ Grants access to the Username Replacement API for anyone in the group, diff --git a/openedx/core/djangoapps/user_api/accounts/views.py b/openedx/core/djangoapps/user_api/accounts/views.py index d32c214448..8f243ac863 100644 --- a/openedx/core/djangoapps/user_api/accounts/views.py +++ b/openedx/core/djangoapps/user_api/accounts/views.py @@ -1006,6 +1006,7 @@ class AccountRetirementView(ViewSet): for entitlement in CourseEntitlement.objects.filter(user_id=user.id): entitlement.courseentitlementsupportdetail_set.all().update(comments='') + class UsernameReplacementView(APIView): """ WARNING: This API is only meant to be used as part of a larger job that @@ -1163,4 +1164,3 @@ class UsernameReplacementView(APIView): new=new_username, )) return True -