72 # sign_representation = ' - '.join(sign[:k]) + '\n' + ' - '.join(sign[k:]) |
72 # sign_representation = ' - '.join(sign[:k]) + '\n' + ' - '.join(sign[k:]) |
73 return sign_representation |
73 return sign_representation |
74 else: |
74 else: |
75 return schedule_entry['trip'].schedule[-1].stop.name |
75 return schedule_entry['trip'].schedule[-1].stop.name |
76 |
76 |
|
77 def imminent(schedule_entry): |
|
78 return (schedule_entry['time'] - now()) <= timedelta(minutes = 3) |
|
79 |
77 @app.route('/pysäkki/<reference>') |
80 @app.route('/pysäkki/<reference>') |
78 def bus_stop_schedule(reference): |
81 def bus_stop_schedule(reference): |
79 from buses import bus_stops |
82 from buses import bus_stops |
80 schedule = [] |
83 schedule = [] |
81 try: |
84 try: |
87 'time': time_representation(schedule_entry['time']), |
90 'time': time_representation(schedule_entry['time']), |
88 'route': schedule_entry['trip'].route.reference, |
91 'route': schedule_entry['trip'].route.reference, |
89 'sign': sign(schedule_entry), |
92 'sign': sign(schedule_entry), |
90 'trip': schedule_entry['stop'].trip.name, |
93 'trip': schedule_entry['stop'].trip.name, |
91 'night': is_night_time(schedule_entry['time']), |
94 'night': is_night_time(schedule_entry['time']), |
|
95 'imminent': imminent(schedule_entry), |
92 }) |
96 }) |
93 return render_template( |
97 return render_template( |
94 'stop.html', |
98 'stop.html', |
95 schedule = schedule, |
99 schedule = schedule, |
96 name = bus_stop.code + ' ' + tr(bus_stop.name, 'bus_stops'), |
100 name = bus_stop.code + ' ' + tr(bus_stop.name, 'bus_stops'), |
132 'trip': schedule_entry['stop'].trip.name, |
136 'trip': schedule_entry['stop'].trip.name, |
133 'night': is_night_time(schedule_entry['time']), |
137 'night': is_night_time(schedule_entry['time']), |
134 'stop_id': schedule_entry['stop'].stop.reference, |
138 'stop_id': schedule_entry['stop'].stop.reference, |
135 'stop_code': schedule_entry['stop'].stop.code, |
139 'stop_code': schedule_entry['stop'].stop.code, |
136 'stop_name': tr(schedule_entry['stop'].stop.name, 'pysäkit'), |
140 'stop_name': tr(schedule_entry['stop'].stop.name, 'pysäkit'), |
|
141 'imminent': imminent(schedule_entry), |
137 }) |
142 }) |
138 stops_in_cluster = sorted( |
143 stops_in_cluster = sorted( |
139 ({ |
144 ({ |
140 'id': stop.reference, |
145 'id': stop.reference, |
141 'code': stop.code, |
146 'code': stop.code, |