Fix the single-lot view.

This commit is contained in:
Bradlee Speice 2013-10-18 18:40:05 -04:00
parent 92b8bb6392
commit 664aec18ab
2 changed files with 7 additions and 3 deletions

View File

@ -1,9 +1,11 @@
from django.conf.urls import url, patterns
import views
from rest_framework.urlpatterns import format_suffix_patterns
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('^lots/(?P<lot>\w+)/$', views.SingleParkingLotList.as_view(), name='parking-lot'),
url('^rate/$', views.RateLot.as_view(), name='parking-rating'),
)

View File

@ -7,6 +7,7 @@ from rest_framework import status
from rest_framework.decorators import api_view
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
@api_view(('GET',))
def api_root(request):
@ -32,8 +33,9 @@ class SingleParkingLotList(APIView):
"""
def get(self, request, lot):
parking_lot = ParkingLot.objects.filter(location=lot)
return Response(ParkingLotSerializer(parking_lot))
print "Received lot: '" + lot + "'"
parking_lot = get_object_or_404(ParkingLot, location=lot)
return Response(ParkingLotSerializer(parking_lot).data)
class RateLot(APIView):
"""