mirror of
https://github.com/bspeice/UNCCGameDay-Server
synced 2024-12-04 13:58:14 -05:00
Fix the single-lot view.
This commit is contained in:
parent
92b8bb6392
commit
664aec18ab
@ -1,9 +1,11 @@
|
|||||||
from django.conf.urls import url, patterns
|
from django.conf.urls import url, patterns
|
||||||
import views
|
import views
|
||||||
|
|
||||||
|
from rest_framework.urlpatterns import format_suffix_patterns
|
||||||
|
|
||||||
urlpatterns = patterns('gameday.views',
|
urlpatterns = patterns('gameday.views',
|
||||||
url('^$', 'api_root'),
|
url('^$', 'api_root'),
|
||||||
url('^lots/$', views.ParkingLotList.as_view(), name='parking-lots'),
|
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'),
|
url('^rate/$', views.RateLot.as_view(), name='parking-rating'),
|
||||||
)
|
)
|
||||||
|
@ -7,6 +7,7 @@ from rest_framework import status
|
|||||||
from rest_framework.decorators import api_view
|
from rest_framework.decorators import api_view
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
@api_view(('GET',))
|
@api_view(('GET',))
|
||||||
def api_root(request):
|
def api_root(request):
|
||||||
@ -32,8 +33,9 @@ class SingleParkingLotList(APIView):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def get(self, request, lot):
|
def get(self, request, lot):
|
||||||
parking_lot = ParkingLot.objects.filter(location=lot)
|
print "Received lot: '" + lot + "'"
|
||||||
return Response(ParkingLotSerializer(parking_lot))
|
parking_lot = get_object_or_404(ParkingLot, location=lot)
|
||||||
|
return Response(ParkingLotSerializer(parking_lot).data)
|
||||||
|
|
||||||
class RateLot(APIView):
|
class RateLot(APIView):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user