|
|
@@ -1,16 +1,13 @@ |
|
|
|
from rest_framework.response import Response |
|
|
|
from rest_framework.views import APIView |
|
|
|
from rest_framework import viewsets |
|
|
|
from rest_framework.authentication import TokenAuthentication, SessionAuthentication |
|
|
|
from rest_framework.permissions import IsAuthenticated |
|
|
|
from .models import Employee |
|
|
|
from .serializers import EmployeeSerializer |
|
|
|
|
|
|
|
|
|
|
|
class EmployeeList(APIView): |
|
|
|
class EmployeeViewSet(viewsets.ReadOnlyModelViewSet): |
|
|
|
queryset = Employee.objects.all() |
|
|
|
serializer_class = EmployeeSerializer |
|
|
|
authentication_classes = [TokenAuthentication, SessionAuthentication] |
|
|
|
permission_classes = [IsAuthenticated] |
|
|
|
|
|
|
|
def get(self, request): |
|
|
|
employees = Employee.objects.all() |
|
|
|
serializer = EmployeeSerializer(employees, many=True) |
|
|
|
return Response(serializer.data) |