import json; change code to alias in route api lookup

This commit is contained in:
Sanj 2012-02-19 17:46:18 +05:30
parent 1c16d27d99
commit fe3c276ec7
3 changed files with 5 additions and 3 deletions

View File

@ -2,5 +2,5 @@ from django.conf.urls.defaults import *
import apiviews
urlpatterns = patterns('',
(r'^route/(?P<code>[0-9]*)$', apiviews.route),
(r'^route/(?P<alias>.*)$', apiviews.route), #FIXME: better regexp for route alias?
)

View File

@ -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(),

View File

@ -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'),