125 'trip': schedule_entry['stop'].trip.name, |
125 'trip': schedule_entry['stop'].trip.name, |
126 'night': is_night_time(schedule_entry['time']), |
126 'night': is_night_time(schedule_entry['time']), |
127 'stop_id': schedule_entry['stop'].stop.reference, |
127 'stop_id': schedule_entry['stop'].stop.reference, |
128 'stop_name': tr(schedule_entry['stop'].stop.name, 'bus_stops'), |
128 'stop_name': tr(schedule_entry['stop'].stop.name, 'bus_stops'), |
129 }) |
129 }) |
|
130 stops_in_cluster = sorted( |
|
131 ({ |
|
132 'id': stop.reference, |
|
133 'name': tr(stop.name, 'bus_stops'), |
|
134 } for stop in cluster.stops), |
|
135 key = lambda stop: (len(stop['id']), stop['id']) |
|
136 ) |
130 return render_template( |
137 return render_template( |
131 'cluster.html', |
138 'cluster.html', |
132 schedule = schedule, |
139 schedule = schedule, |
133 name = cluster.name, |
140 name = cluster.name, |
134 link_to_map = cluster.center.link_to_map, |
141 link_to_map = cluster.center.link_to_map, |
135 location = cluster.center, |
142 location = cluster.center, |
136 stops_in_cluster = sorted( |
143 stops_in_cluster = stops_in_cluster, |
137 ({ |
144 amount_of_stops_in_cluster = len(stops_in_cluster), |
138 'id': stop.reference, |
|
139 'name': tr(stop.name, 'bus_stops'), |
|
140 } for stop in cluster.stops), |
|
141 key = lambda stop: (len(stop['id']), stop['id']) |
|
142 ), |
|
143 tr = tr, |
145 tr = tr, |
144 ) |
146 ) |
145 |
147 |
146 @app.route('/ajovuoro/<trip_reference>') |
148 @app.route('/ajovuoro/<trip_reference>') |
147 def trip(trip_reference): |
149 def trip(trip_reference): |
181 trip_reference = trip_reference, |
183 trip_reference = trip_reference, |
182 route = trip.route.reference, |
184 route = trip.route.reference, |
183 description = ' - '.join(tr(place, 'paikat') for place in sign), |
185 description = ' - '.join(tr(place, 'paikat') for place in sign), |
184 night = is_night_time(datetime.combine(today(), time()) + trip.schedule[-1].arrival_time), |
186 night = is_night_time(datetime.combine(today(), time()) + trip.schedule[-1].arrival_time), |
185 tr = tr, |
187 tr = tr, |
186 length = trip.length / 1000 |
188 length = trip.length / 1000, |
|
189 ) |
|
190 |
|
191 @app.route('/linja/<name>') |
|
192 def route_page(name): |
|
193 from buses import routes |
|
194 route = routes[name.upper()] |
|
195 schedule = [] |
|
196 for trip in route.trips: |
|
197 if trip.is_served_at(today()) and datetime.combine(today(), time()) + trip.schedule[-1].arrival_time < now(): |
|
198 schedule.append({ |
|
199 'name': trip.reference, |
|
200 'from': trip.from_place, |
|
201 'to': trip.to_place, |
|
202 'time': time_representation(datetime.combine(today(), time()) + trip.schedule[0].departure_time), |
|
203 }) |
|
204 return render_template('route.html', |
|
205 name = route.reference + ' ' + route.description, |
|
206 tr = tr, |
|
207 schedule = schedule, |
187 ) |
208 ) |
188 |
209 |
189 @app.route('/static/<path:path>') |
210 @app.route('/static/<path:path>') |
190 def static_file(path): |
211 def static_file(path): |
191 return send_from_directory(path.join('static', path)) |
212 return send_from_directory(path.join('static', path)) |