Add a single-lot view

master
Bradlee Speice 2013-10-18 18:10:28 -04:00
parent 4bd46f9e71
commit 92b8bb6392
3 changed files with 14 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,8 +1,9 @@
*.pyc
*.sqlite
*.sublime*
*.swp
bin/
include/
lib/
local/
.codeintel/
.codeintel/

View File

@ -4,5 +4,6 @@ import views
urlpatterns = patterns('gameday.views',
url('^$', 'api_root'),
url('^lots/$', views.ParkingLotList.as_view(), name='parking-lots'),
url('^lots/(?P<lot>)$', views.SingleParkingLotList.as_view(), name='parking-lot'),
url('^rate/$', views.RateLot.as_view(), name='parking-rating'),
)
)

View File

@ -26,6 +26,15 @@ class ParkingLotList(APIView):
serializer = ParkingLotSerializer(parking_lots, many=True)
return Response(serializer.data)
class SingleParkingLotList(APIView):
"""
List a single parking lot
"""
def get(self, request, lot):
parking_lot = ParkingLot.objects.filter(location=lot)
return Response(ParkingLotSerializer(parking_lot))
class RateLot(APIView):
"""
Rate a parking lot
@ -43,4 +52,4 @@ class RateLot(APIView):
def get(self, request):
'Get the rating choice options'
return Response(ParkingRating.RATING_CHOICES)
return Response(ParkingRating.RATING_CHOICES)