Django backend for WorkX project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Deze repo is gearchiveerd. U kunt bestanden bekijken en het klonen, maar niet pushen of problemen/pull-requests openen.

57 regels
1.9 KiB

  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 TaxType, Country, State, City, Client
  6. from .serializers import TaxTypeSerializer, CountrySerializer, StateSerializer, CitySerializer, ClientSerializer
  7. class TaxTypeList(APIView):
  8. authentication_classes = [TokenAuthentication, SessionAuthentication]
  9. permission_classes = [IsAuthenticated]
  10. def get(self, request):
  11. tax_types = TaxType.objects.all()
  12. serializer = TaxTypeSerializer(tax_types, many=True)
  13. return Response(serializer.data)
  14. class CountryList(APIView):
  15. authentication_classes = [TokenAuthentication, SessionAuthentication]
  16. permission_classes = [IsAuthenticated]
  17. def get(self, request):
  18. countries = Country.objects.all()
  19. serializer = CountrySerializer(countries, many=True)
  20. return Response(serializer.data)
  21. class StateList(APIView):
  22. authentication_classes = [TokenAuthentication, SessionAuthentication]
  23. permission_classes = [IsAuthenticated]
  24. def get(self, request):
  25. states = State.objects.all()
  26. serializer = StateSerializer(states, many=True)
  27. return Response(serializer.data)
  28. class CityList(APIView):
  29. authentication_classes = [TokenAuthentication, SessionAuthentication]
  30. permission_classes = [IsAuthenticated]
  31. def get(self, request):
  32. cities = City.objects.all()
  33. serializer = CitySerializer(cities, many=True)
  34. return Response(serializer.data)
  35. class ClientList(APIView):
  36. authentication_classes = [TokenAuthentication, SessionAuthentication]
  37. permission_classes = [IsAuthenticated]
  38. def get(self, request):
  39. clients = Client.objects.all()
  40. serializer = ClientSerializer(clients, many=True)
  41. return Response(serializer.data)