From 89b46e1bcedf72c0066721234f64b24c07c78b6a Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 19 Feb 2012 20:01:00 +0530 Subject: [PATCH] add call for area --- chaloBEST/mumbai/apiurls.py | 1 + chaloBEST/mumbai/apiviews.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/chaloBEST/mumbai/apiurls.py b/chaloBEST/mumbai/apiurls.py index ba5c793..b33c5c2 100644 --- a/chaloBEST/mumbai/apiurls.py +++ b/chaloBEST/mumbai/apiurls.py @@ -3,6 +3,7 @@ import apiviews urlpatterns = patterns('', (r'^route/(?P.*)$', apiviews.route), #FIXME: better regexp for route alias? + (r'^area/(?P.*)$', apiviews.area), (r'^stop/(?P.*)$', apiviews.stop), (r'^routes/$', apiviews.routes), (r'^areas/$', apiviews.areas), diff --git a/chaloBEST/mumbai/apiviews.py b/chaloBEST/mumbai/apiviews.py index 36609ab..ec0fb37 100644 --- a/chaloBEST/mumbai/apiviews.py +++ b/chaloBEST/mumbai/apiviews.py @@ -14,6 +14,13 @@ def route(request, slug): } }) +def area(request, slug) + area = get_object_or_404_json(Area, slug=slug) + stops = [stop.get_geojson() for stop in Stop.objects.filter(area=area)] + return render_to_json_response({ + 'type': 'FeatureCollection', + 'features': stops + }) def routes(request): qset = Route.objects.all()