Skip to content

Commit

Permalink
Remove registration view
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Rusakov committed Nov 19, 2024
1 parent 6f80814 commit 5b88b2d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 75 deletions.
37 changes: 0 additions & 37 deletions api/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': '[email protected]',
'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': '[email protected]',
'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
Expand Down
36 changes: 0 additions & 36 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<key>[-:\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<pk>[0-9]+)$',
Expand Down

0 comments on commit 5b88b2d

Please sign in to comment.