Exemplo n.º 1
0
Arquivo: views.py Projeto: kkaushy/lms
 def put(self, request, pk, format=None):
     employee = self.get_object(pk)
     serializer = EmployeeSerializer(employee, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 2
0
 def test_get_employee(self):
     self.client.force_login(self.user)
     response = self.client.get(reverse("employee-list"))
     employees = Employee.objects.all()
     serialized_employees = EmployeeSerializer(employees, many=True)
     self.assertEqual(response.data, serialized_employees.data)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemplo n.º 3
0
Arquivo: views.py Projeto: kkaushy/lms
 def post(self, request, format=None):
     serializer = EmployeeSerializer(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)