From 5b88b2dc1f001ef5b79af7ec7588105764a79fe3 Mon Sep 17 00:00:00 2001 From: Andrey Rusakov Date: Tue, 19 Nov 2024 14:32:58 +0100 Subject: [PATCH] Remove registration view --- api/tests/test_user.py | 37 ------------------------------------- api/views.py | 36 ------------------------------------ urls.py | 2 -- 3 files changed, 75 deletions(-) diff --git a/api/tests/test_user.py b/api/tests/test_user.py index ac745c7e..640cdf64 100644 --- a/api/tests/test_user.py +++ b/api/tests/test_user.py @@ -33,43 +33,6 @@ def setUp(self): self.assertTrue('access' in resp.data) self.token = resp.data['access'] - def test_user_create_private(self): - url = reverse('auth_register') - data = { - 'username': 'jdupond', - 'first_name': 'Jean', - 'last_name': 'Dupond', - 'street': 'Tivoli 22', - 'city': 'Neuchâtel-les-Bains', - 'email': 'admin@gmail.com', - 'password1': 'testPa$$word', - 'password2': 'testPa$$word' - } - response = self.client.post(url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_200_OK, response.content) - self.assertEqual(len(mail.outbox), 2, 'An email has been sent to admins and to the new user') - - def test_user_create_with_company(self): - url = reverse('auth_register') - data = { - 'username': 'jdupond', - 'first_name': 'Jean', - 'last_name': 'Dupond', - 'street': 'Tivoli 22', - 'city': 'Neuchâtel-les-Bains', - 'email': 'admin@gmail.com', - 'company_name': 'SITN', - 'ide_id': 'CHE-25', - 'password1': 'testPa$$word', - 'password2': 'testPa$$word' - } - response = self.client.post(url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, 'IDE number is not valid') - data['ide_id'] = 'CHE-999.999.999' - response = self.client.post(url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_200_OK, response.content) - self.assertEqual(len(mail.outbox), 2, 'An email has been sent to admins and to the new user') - def test_user_change(self): """ Tests POST of an user change request diff --git a/api/views.py b/api/views.py index 1d4ccf85..fd0fd217 100644 --- a/api/views.py +++ b/api/views.py @@ -499,42 +499,6 @@ class PricingViewSet(viewsets.ReadOnlyModelViewSet): queryset = Pricing.objects.all() serializer_class = PricingSerializer - -class RegisterView(generics.CreateAPIView): - """ - API endpoint that allows users to register. - """ - queryset = UserModel.objects.all().order_by('-date_joined') - serializer_class = RegisterSerializer - permission_classes = [permissions.AllowAny] - authentication_classes = [] - - def post(self, request, *args, **kwargs): - response = super(RegisterView, self).post(request, *args, **kwargs) - user = UserModel.objects.get(pk=response.data['id']) - user.is_active = False - user.save() - send_geoshop_email( - _('Geoshop - New user request'), - template_name='email_admin', - template_data={ - 'messages': [_('A new user account needs to be validated:')], - 'admin_url': 'admin:auth_user_change', - 'admin_url_params': user.id, - 'current_site':request.get_host(), - 'protocol': request.scheme - } - ) - send_geoshop_email( - _('Geoshop - New account pending'), - recipient=user.identity, - template_name='email_welcome_user', - template_data=UserIdentitySerializer(user).data - ) - - return Response({'detail': _('Your data was successfully submitted')}, status=status.HTTP_200_OK) - - class OrderByUUIDView(generics.RetrieveAPIView): """ Returns an order based on in its UUID diff --git a/urls.py b/urls.py index 232854c0..e36f2a41 100644 --- a/urls.py +++ b/urls.py @@ -55,7 +55,6 @@ router.register_additional_route_to_root(f'{ROOTURL}auth/current', 'auth_current_user') router.register_additional_route_to_root(f'{ROOTURL}auth/password', 'auth_password') router.register_additional_route_to_root(f'{ROOTURL}auth/password/confirm', 'auth_password_confirm') -router.register_additional_route_to_root(f'{ROOTURL}auth/register', 'auth_register') # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. @@ -75,7 +74,6 @@ path(f'{ROOTURL}auth/verify-email/', views.VerifyEmailView.as_view(), name='auth_verify_email'), re_path(rf'^{ROOTURL}auth/account-confirm-email/(?P[-:\w]+)/$', TemplateView.as_view(), name='account_confirm_email'), - path(f'{ROOTURL}auth/register/', views.RegisterView.as_view(), name='auth_register'), path(f'{ROOTURL}extract/order/', views.ExtractOrderView.as_view(), name='extract_order'), path(f'{ROOTURL}extract/orderitem/', views.ExtractOrderItemView.as_view(), name='extract_orderitem'), re_path(rf'^{ROOTURL}extract/orderitem/(?P[0-9]+)$',