fix error in /stops/ api call
This commit is contained in:
parent
d61cccf204
commit
9a81c6e254
|
@ -67,9 +67,9 @@ def areas(request):
|
|||
def stops(request):
|
||||
q = request.GET.get("q", "")
|
||||
if q != '':
|
||||
qset = Stop.objects.find_approximate(q, TRIGRAM_THRESHOLD)
|
||||
qset = Stop.objects.find_approximate(q, TRIGRAM_THRESHOLD).select_related()
|
||||
else:
|
||||
qset = Stop.objects.all()
|
||||
qset = Stop.objects.all().select_related()
|
||||
srid = int(request.GET.get("srid", 4326))
|
||||
return render_to_json_response({
|
||||
'type': 'FeatureCollection',
|
||||
|
|
|
@ -144,6 +144,10 @@ class Stop(models.Model):
|
|||
alt_names = generic.GenericRelation("AlternativeName")
|
||||
|
||||
def get_dict(self):
|
||||
routes = []
|
||||
for r in self.routedetail_set.all():
|
||||
if r.route is not None:
|
||||
routes.append(r.route)
|
||||
return {
|
||||
'id': self.id,
|
||||
'code': self.code,
|
||||
|
@ -154,7 +158,7 @@ class Stop(models.Model):
|
|||
'area': self.area.name,
|
||||
'name_mr': self.name_mr,
|
||||
'direction': self.dbdirection,
|
||||
'routes': ", ".join([r.route.alias for r in RouteDetail.objects.filter(stop=self)]),
|
||||
'routes': ", ".join([r.alias for r in routes]),
|
||||
'alternative_names': ", ".join([a.name for a in self.alt_names.all().filter(typ='common')])
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user