logbook-django/logbook/flight/views.py

37 lines
971 B
Python
Raw Normal View History

2019-09-16 00:32:42 +00:00
from rest_framework import viewsets
from flight.serializers import (
PlaneSerializer,
AirportSerializer,
FlightSerializer,
UserSerializer,
GroupSerializer,
)
2019-09-16 00:32:42 +00:00
from flight.models import Flight, Plane, Airport
from django.contrib.auth.models import User, Group
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all().order_by("-date_joined")
serializer_class = UserSerializer
class GroupViewSet(viewsets.ModelViewSet):
queryset = Group.objects.all()
serializer_class = GroupSerializer
2019-09-15 05:38:18 +00:00
2019-09-16 00:32:42 +00:00
class PlaneViewSet(viewsets.ModelViewSet):
queryset = Plane.objects.all().order_by("tail_number")
serializer_class = PlaneSerializer
class AirportViewSet(viewsets.ModelViewSet):
queryset = Airport.objects.all().order_by("icao")
serializer_class = AirportSerializer
class FlightViewSet(viewsets.ModelViewSet):
queryset = Flight.objects.all().order_by("-flight_date")
serializer_class = FlightSerializer