コード例 #1
0
    def list(self, request, *args, **kwargs):
        if request.GET.get('route', ' ') != ' ':
            this_route_number = request.GET.get('route', ' ')

            try:
                stops = PassengerCensus.objects.filter(
                    route_number=this_route_number)
                if stops.exists():
                    if request.GET.get('year', ' ') != ' ':
                        this_year = request.GET.get('year', ' ')
                        try:
                            stops = stops.filter(
                                summary_begin_date__year=this_year)
                        except ValueError:
                            return Response(
                                'Search year must be four digit year',
                                status=status.HTTP_400_BAD_REQUEST)
                    if stops.exists():
                        weekly = getTotals(stops)
                        return Response(weekly)
                else:
                    return Response('Route Number not found',
                                    status=status.HTTP_404_NOT_FOUND)
            except ValueError:
                return Response('Route Number must be integer',
                                status=status.HTTP_400_BAD_REQUEST)
        else:
            return Response('Missing Route Number paramater',
                            status=status.HTTP_400_BAD_REQUEST)
コード例 #2
0
 def list(self, request, *args, **kwargs):
     census = PassengerCensus.objects.filter(route_number__in=[
         "1", "2", "4", "4", "6", "8", "9", "10", "11", "12", "14", "15",
         "16", "17", "18", "19", "20", "20", "21", "22", "23", "24", "25",
         "29", "30", "32", "33", "34", "35", "36", "37", "38", "39", "42",
         "43", "44", "45", "46", "47", "48", "50", "51", "52", "53", "54",
         "55", "56", "57", "58", "59", "61", "62", "63", "64", "65", "66",
         "67", "68", "70", "71", "72", "73", "74", "75", "76", "77", "78",
         "79", "80", "81", "82", "84", "85", "87", "88", "90", "92", "93",
         "94", "96", "97", "99", "152", "154", "155", "156", "203", "272",
         "291"
     ])
     weekly = getTotals(census)
     return Response(weekly)
コード例 #3
0
 def list(self, request, *args, **kwargs):
     census = PassengerCensus.objects.all()
     weekly = getTotals(census)
     return Response(weekly)
コード例 #4
0
 def list(self, request, *args, **kwargs):
     census = PassengerCensus.objects.filter(route_number__in=["208"])
     weekly = getTotals(census)
     return Response(weekly)