def post(self, request):
     serializer = serializers.AdminUserLoginSerializer(data=request.data)
     if serializer.is_valid():
         session_data = serializer.save()
         return Response(session_data, status=status.HTTP_200_OK)
     return Response({'error': error_wrapper(serializer.errors)},
                     status=status.HTTP_401_UNAUTHORIZED)
Beispiel #2
0
 def post(self, request):
     serializer = serializers.UserRegistrationSerializer(data=request.data)
     if serializer.is_valid():
         session_data = serializer.save()
         return Response(session_data, status=status.HTTP_200_OK)
     return Response({'error': error_wrapper(serializer.errors)},
                     status=status.HTTP_400_BAD_REQUEST)
Beispiel #3
0
 def post(self, request):
     serializer = serializers.UserGoogleRegistrationSerializer(
         data=request.data)
     print("inside correct function")
     if serializer.is_valid():
         print("data is valid")
         session_data = serializer.save()
         return Response(session_data, status=status.HTTP_200_OK)
     return Response({'error': error_wrapper(serializer.errors)},
                     status=status.HTTP_400_BAD_REQUEST)
Beispiel #4
0
    def post(self, request):

        print(request.data)
        consti = get_object_or_404(Constituency,
                                   name=request.data["constituency"])
        serializer = serializers.KycInfoSerializer(data=request.data)
        if serializer.is_valid():
            new_voter = serializer.save()
            new_voter.constituency = consti
            new_voter.save()
            return Response(serializer.data, status=status.HTTP_200_OK)
        return Response({'error': error_wrapper(serializer.errors)},
                        status=status.HTTP_400_BAD_REQUEST)