From fe3c276ec743e1efb8adebebba5baea6eae8611a Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 19 Feb 2012 17:46:18 +0530 Subject: [PATCH] import json; change code to alias in route api lookup --- chaloBEST/mumbai/apiurls.py | 2 +- chaloBEST/mumbai/apiviews.py | 5 +++-- chaloBEST/mumbai/models.py | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chaloBEST/mumbai/apiurls.py b/chaloBEST/mumbai/apiurls.py index 15ce22b..56704dc 100644 --- a/chaloBEST/mumbai/apiurls.py +++ b/chaloBEST/mumbai/apiurls.py @@ -2,5 +2,5 @@ from django.conf.urls.defaults import * import apiviews urlpatterns = patterns('', - (r'^route/(?P[0-9]*)$', apiviews.route), + (r'^route/(?P.*)$', apiviews.route), #FIXME: better regexp for route alias? ) diff --git a/chaloBEST/mumbai/apiviews.py b/chaloBEST/mumbai/apiviews.py index 5e31772..2c7044f 100644 --- a/chaloBEST/mumbai/apiviews.py +++ b/chaloBEST/mumbai/apiviews.py @@ -1,8 +1,9 @@ from models import * from ox.django.shortcuts import get_object_or_404_json, render_to_json_response -def route(request, code): - route = get_object_or_404_json(Route, code=code) + +def route(request, alias): + route = get_object_or_404_json(Route, alias=alias) stops = [r.stop.get_geojson() for r in RouteDetail.objects.filter(route=route)] return render_to_json_response({ 'route': route.get_dict(), diff --git a/chaloBEST/mumbai/models.py b/chaloBEST/mumbai/models.py index a896524..b8aca72 100644 --- a/chaloBEST/mumbai/models.py +++ b/chaloBEST/mumbai/models.py @@ -2,6 +2,7 @@ from django.contrib.gis.db import models from django import forms from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic +import json STOP_CHOICES = ( ('U','Up'), ('D', 'Down'),