Django backend for WorkX project
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
Це архівний репозитарій. Ви можете переглядати і клонувати файли, але не можете робити пуш або відкривати питання/запити.

3 роки тому
3 роки тому
1234567891011121314151617181920212223242526
  1. from rest_framework.response import Response
  2. from rest_framework.views import APIView
  3. from rest_framework.authentication import TokenAuthentication, SessionAuthentication
  4. from rest_framework.permissions import IsAuthenticated
  5. from .models import Representative, Role
  6. from .serializers import RoleSerializer, RepresentativeSerializer
  7. class RoleList(APIView):
  8. authentication_classes = [TokenAuthentication, SessionAuthentication]
  9. permission_classes = [IsAuthenticated]
  10. def get(self, request):
  11. roles = Role.objects.all()
  12. serializer = RoleSerializer(roles, many=True)
  13. return Response(serializer.data)
  14. class RepresentativeList(APIView):
  15. authentication_classes = [TokenAuthentication, SessionAuthentication]
  16. permission_classes = [IsAuthenticated]
  17. def get(self, request):
  18. representatives = Representative.objects.all()
  19. serializer = RepresentativeSerializer(representatives, many=True)
  20. return Response(serializer.data)