def post(self, request): """ Implements the retirement endpoint. """ username = request.data['username'] try: retirement = UserRetirementStatus.get_retirement_for_retirement_action(username) delete_all_notes_for_user(retirement.user) except UserRetirementStatus.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) except RetirementStateError as exc: return Response(text_type(exc), status=status.HTTP_405_METHOD_NOT_ALLOWED) except Exception as exc: # pylint: disable=broad-except return Response(text_type(exc), status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(status=status.HTTP_204_NO_CONTENT)
def post(self, request): """ Implements the retirement endpoint. """ username = request.data['username'] try: retirement = UserRetirementStatus.get_retirement_for_retirement_action(username) delete_all_notes_for_user(retirement.user) except UserRetirementStatus.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) except RetirementStateError as exc: return Response(text_type(exc), status=status.HTTP_405_METHOD_NOT_ALLOWED) except Exception as exc: # pylint: disable=broad-except return Response(text_type(exc), status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(status=status.HTTP_204_NO_CONTENT)
def test_delete_all_notes_for_user(self, mock_delete): """ Test GDPR data deletion for Notes user_id """ with mock.patch('edxnotes.helpers.get_edxnotes_id_token', return_value="test_token"): helpers.delete_all_notes_for_user(user=self.user, user_id="anonymous_id") mock_delete.assert_called_with( url='http://example.com/', headers={ 'x-annotator-auth-token': 'test_token' }, data={ 'user_id': 'anonymous_id' }, timeout=(settings.EDXNOTES_CONNECT_TIMEOUT, settings.EDXNOTES_READ_TIMEOUT) )