Exemplo n.º 1
0
 def post(self, request):
     serializer = AddToCartSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return createResponse(True, "Success", serializer.data, 'data')
     else:
         return createResponse(False, "Fail", serializer.errors, 'errors')
Exemplo n.º 2
0
 def post(self, request, format=None):
     serializer = NurseryRegisterSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         user = User.objects.get(username=request.data['username'])
         refresh = get_tokens_for_user(user)
         access = refresh['access']
     else:
         return createResponse(False, "Registration Failed",
                               serializer.errors, "errors")
     return createResponse(True, "Nursery Successfully Registered", {
         'details': serializer.data,
         'access': access
     }, 'data')
Exemplo n.º 3
0
    def post(self, request, format=None):
        serializer = LoginSerializer(data=request.data)

        if serializer.is_valid():
            serializer.save()
            user = User.objects.get(username=request.data['username'])
            refresh = get_tokens_for_user(user)
            access = refresh['access']
            return createResponse(True, "Successfully logged In", {
                'username': serializer.data['username'],
                'access': access
            }, 'data')
        else:
            return createResponse(False, "Login failed", serializer.errors,
                                  "errors")
Exemplo n.º 4
0
 def get(self, request, format=None):
     obj = NurseryPlant.objects.all()
     serializer = GetNurseryPlant(obj, many=True)
     return createResponse(True, 'Sucess', serializer.data, 'data')