bzr merge, dur

This commit is contained in:
Schuyler Erle 2012-02-28 11:49:58 -08:00
commit 3a3e5d20f2
3 changed files with 19 additions and 15 deletions

View File

@ -51,7 +51,7 @@ class FareAdmin(admin.ModelAdmin):
class UniqueRouteAdmin(admin.ModelAdmin): class UniqueRouteAdmin(admin.ModelAdmin):
list_display = ("route","from_stop", "to_stop","distance","is_full") list_display = ("route","from_stop", "to_stop","distance","is_full")
readonly_fields = ("route","from_stop", "to_stop","distance","is_full") readonly_fields = ("route","from_stop", "to_stop","distance","is_full")
search_fields = ("route", "from_stop__name", "to_stop__name") search_fields = ("route__alias", "from_stop__name", "to_stop__name")
ordering = ('route',) ordering = ('route',)
list_per_page = 50 list_per_page = 50

View File

@ -29,28 +29,31 @@ def area(request, slug):
}) })
def routes(request): def routes(request):
qset = Route.objects.all() q = request.GET.get("q", "")
if request.GET.has_key('q'): if q != '':
q = request.GET.get('q', '') qset = Route.objects.filter(alias__icontains=q)
qset = qset.filter(alias__icontains=q) #FIXME: make a better Q object else:
qset = Route.objects.all()
routes = [route.alias for route in qset] routes = [route.alias for route in qset]
return render_to_json_response(routes) return render_to_json_response(routes)
def areas(request): def areas(request):
qset = Area.objects.all() q = request.GET.get("q", "")
if request.GET.has_key('q'): if q != '':
q = request.GET.get('q', '') qset = Area.objects.find_approximate(q, 0.33)
qset = qset.filter(display_name__icontains=q) else:
qset = Area.objects.all()
areas = [area.slug for area in qset] areas = [area.slug for area in qset]
return render_to_json_response(areas) return render_to_json_response(areas)
def stops(request): def stops(request):
qset = Stop.objects.all() q = request.GET.get("q", "")
srid = int(request.GET.get("srid", 4326)) if q != '':
if request.GET.has_key('q'): qset = Stop.objects.find_approximate(q, 0.33)
q = request.GET.get('q', '') else:
qset = qset.filter(display_name__icontains=q) #FIXME: This definitely needs to be a Q object with OR lookups for area name, road name, etc. qset = Stop.objects.all()
srid = int(request.GET.get("srid", 4326))
return render_to_json_response({ return render_to_json_response({
'type': 'FeatureCollection', 'type': 'FeatureCollection',
'features': [stop.get_geojson(srid=srid) for stop in qset] 'features': [stop.get_geojson(srid=srid) for stop in qset]

View File

@ -23,7 +23,7 @@ var API_BASE = "/1.0/",
var $li = $('<div />') var $li = $('<div />')
.addClass("listItem") .addClass("listItem")
.appendTo($list); .appendTo($list);
var $txt = $('<span >').addClass("listItemText").text(v).appendTo($li); var $txt = $('<span />').addClass("listItemText").text(v).appendTo($li);
}); });
}); });
} }
@ -51,6 +51,7 @@ var API_BASE = "/1.0/",
$('.selectedListItem').find(".stopsList").hide().remove(); $('.selectedListItem').find(".stopsList").hide().remove();
$('.selectedListItem').removeClass("selectedListItem"); $('.selectedListItem').removeClass("selectedListItem");
$target.addClass("selectedListItem"); $target.addClass("selectedListItem");
if ($target.data("hasList")) { if ($target.data("hasList")) {
var $stopsList = $target.find(".stopsList"); var $stopsList = $target.find(".stopsList");
$stopsList.slideDown(); $stopsList.slideDown();