import json; change code to alias in route api lookup
This commit is contained in:
parent
1c16d27d99
commit
fe3c276ec7
|
@ -2,5 +2,5 @@ from django.conf.urls.defaults import *
|
||||||
import apiviews
|
import apiviews
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'^route/(?P<code>[0-9]*)$', apiviews.route),
|
(r'^route/(?P<alias>.*)$', apiviews.route), #FIXME: better regexp for route alias?
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from models import *
|
from models import *
|
||||||
from ox.django.shortcuts import get_object_or_404_json, render_to_json_response
|
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)]
|
stops = [r.stop.get_geojson() for r in RouteDetail.objects.filter(route=route)]
|
||||||
return render_to_json_response({
|
return render_to_json_response({
|
||||||
'route': route.get_dict(),
|
'route': route.get_dict(),
|
||||||
|
|
|
@ -2,6 +2,7 @@ from django.contrib.gis.db import models
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.contrib.contenttypes import generic
|
from django.contrib.contenttypes import generic
|
||||||
|
import json
|
||||||
|
|
||||||
STOP_CHOICES = ( ('U','Up'),
|
STOP_CHOICES = ( ('U','Up'),
|
||||||
('D', 'Down'),
|
('D', 'Down'),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user