Example #1
0
 def post(self, request):
     serializer = AppointmentSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors,
                     status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #2
0
 def put(self, request, pk):
     doctor = self.get_object(pk)
     serializer = AppointmentSerializer(instance=doctor, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #3
0
    def post(self, request):
        serializer = AppointmentSerializer(data=request.data)

        if serializer.is_valid():
            serializer.save()

            return Response(serializer.data, status=status.HTTP_201_CREATED)

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Example #4
0
 def get(self, request, pk):
     doctor = self.get_object(pk)
     serializer = AppointmentSerializer(doctor)
     return Response(serializer.data)
Example #5
0
 def get(self, request):
     doctorList = Appointment.objects.filter(user=self.user)
     serializer = AppointmentSerializer(doctorList, many=True)
     return Response(serializer.data, status=status.HTTP_200_OK)
Example #6
0
    def get(self, request):
        appointment_list = Appointment.objects.all()

        serializer = AppointmentSerializer(appointment_list, many=True)

        return Response(serializer.data, status=status.HTTP_200_OK)