diff -r 69cc75506d4f -r f89504285945 service.py --- a/service.py Tue Jun 20 10:32:50 2017 +0300 +++ b/service.py Wed Jun 21 18:24:34 2017 +0300 @@ -127,19 +127,21 @@ 'stop_id': schedule_entry['stop'].stop.reference, 'stop_name': tr(schedule_entry['stop'].stop.name, 'bus_stops'), }) + stops_in_cluster = sorted( + ({ + 'id': stop.reference, + 'name': tr(stop.name, 'bus_stops'), + } for stop in cluster.stops), + key = lambda stop: (len(stop['id']), stop['id']) + ) return render_template( 'cluster.html', schedule = schedule, name = cluster.name, link_to_map = cluster.center.link_to_map, location = cluster.center, - stops_in_cluster = sorted( - ({ - 'id': stop.reference, - 'name': tr(stop.name, 'bus_stops'), - } for stop in cluster.stops), - key = lambda stop: (len(stop['id']), stop['id']) - ), + stops_in_cluster = stops_in_cluster, + amount_of_stops_in_cluster = len(stops_in_cluster), tr = tr, ) @@ -183,7 +185,26 @@ description = ' - '.join(tr(place, 'paikat') for place in sign), night = is_night_time(datetime.combine(today(), time()) + trip.schedule[-1].arrival_time), tr = tr, - length = trip.length / 1000 + length = trip.length / 1000, + ) + +@app.route('/linja/') +def route_page(name): + from buses import routes + route = routes[name.upper()] + schedule = [] + for trip in route.trips: + if trip.is_served_at(today()) and datetime.combine(today(), time()) + trip.schedule[-1].arrival_time < now(): + schedule.append({ + 'name': trip.reference, + 'from': trip.from_place, + 'to': trip.to_place, + 'time': time_representation(datetime.combine(today(), time()) + trip.schedule[0].departure_time), + }) + return render_template('route.html', + name = route.reference + ' ' + route.description, + tr = tr, + schedule = schedule, ) @app.route('/static/')