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):
q = request.GET.get("q", "")
if q != '':
qset = Route.objects.filter(alias__icontains=q)
else:
qset = Route.objects.all() qset = Route.objects.all()
if request.GET.has_key('q'):
q = request.GET.get('q', '')
qset = qset.filter(alias__icontains=q) #FIXME: make a better Q object
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):
q = request.GET.get("q", "")
if q != '':
qset = Area.objects.find_approximate(q, 0.33)
else:
qset = Area.objects.all() qset = Area.objects.all()
if request.GET.has_key('q'):
q = request.GET.get('q', '')
qset = qset.filter(display_name__icontains=q)
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):
q = request.GET.get("q", "")
if q != '':
qset = Stop.objects.find_approximate(q, 0.33)
else:
qset = Stop.objects.all() qset = Stop.objects.all()
srid = int(request.GET.get("srid", 4326)) srid = int(request.GET.get("srid", 4326))
if request.GET.has_key('q'):
q = request.GET.get('q', '')
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.
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();