views.py 1.14 KB
Newer Older
1
2
3
4
# standard library imports
from __future__ import absolute_import, print_function
# third party imports
from rest_framework.viewsets import ReadOnlyModelViewSet
Daniel W Bond's avatar
Daniel W Bond committed
5
from rest_framework.pagination import PageNumberPagination
6
7
# imports from your apps
from housing.models import Building, Floor, Room
Daniel W Bond's avatar
Daniel W Bond committed
8
9
10
11
12
13
14
15
16
from accounts.models import Major
from .serializers import (BuildingSerializer, FloorSerializer, RoomSerializer,
                          MajorSerializer)


class HousingPagination(PageNumberPagination):
    page_size = 25
    page_size_query_param = 'page_size'
    max_page_size = 1000
17
18
19
20
21


class BuildingAPI(ReadOnlyModelViewSet):
    queryset = Building.objects.all()
    serializer_class = BuildingSerializer
Daniel W Bond's avatar
Daniel W Bond committed
22
    pagination_class = HousingPagination
23
24
25
26
27


class FloorAPI(ReadOnlyModelViewSet):
    queryset = Floor.objects.all()
    serializer_class = FloorSerializer
Daniel W Bond's avatar
Daniel W Bond committed
28
    pagination_class = HousingPagination
29
30
31
32
33


class RoomAPI(ReadOnlyModelViewSet):
    queryset = Room.objects.all()
    serializer_class = RoomSerializer
Daniel W Bond's avatar
Daniel W Bond committed
34
35
36
37
38
39
    pagination_class = HousingPagination


class MajorAPI(ReadOnlyModelViewSet):
    queryset = Major.objects.all()
    serializer_class = MajorSerializer