# HG changeset patch # User Teemu Piippo # Date 1512658544 -7200 # Node ID 5fd79554c3aabd73f2ca5e4d494ebd2e4f15b051 # Parent 4f8a67d5d79e45d8fa2cb0ec8e8077752b33fb8b Stop_display muutoksia diff -r 4f8a67d5d79e -r 5fd79554c3aa service.py --- a/service.py Wed Dec 06 22:47:45 2017 +0200 +++ b/service.py Thu Dec 07 16:55:44 2017 +0200 @@ -268,7 +268,7 @@ bus_stop = bus_stops[reference] except KeyError: abort(404) - for i, schedule_entry in enumerate(bus_stop.schedule_for_day(today(), arrivals = False)[:6]): + for i, schedule_entry in enumerate(bus_stop.schedule_for_day(today(), arrivals = False)): schedule.append({ 'time_data': schedule_entry['time'], 'time': time_representation(schedule_entry['time']), @@ -281,6 +281,17 @@ }) from pprint import pprint pprint(schedule) + def destination_key(schedule_entry): + sign = schedule_entry['sign'] + return (sign['destination'],) + tuple(sign['via']) + def filter_schedule(schedule, *, key): + used = set() + for schedule_entry in schedule: + key_value = key(schedule_entry) + if key_value not in used: + used.add(key_value) + yield schedule_entry + schedule = list(filter_schedule(schedule, key = destination_key))[:6] if schedule: num_imminent_leaves = max(1, len([schedule_entry for schedule_entry in schedule if schedule_entry['time_data'] - schedule[0]['time_data'] < timedelta(minutes = 3)])) else: diff -r 4f8a67d5d79e -r 5fd79554c3aa templates/stop_display.html --- a/templates/stop_display.html Wed Dec 06 22:47:45 2017 +0200 +++ b/templates/stop_display.html Thu Dec 07 16:55:44 2017 +0200 @@ -23,12 +23,14 @@ vertical-align: middle; } - .next-leave-table + .next-leave-list { width: 100%; } - .next-leave-time, .next-leave-destination, .next-leave-route + .next-leave-time, + .next-leave-places li.next-leave-destination, + .next-leave-route { font-weight: bold; font-size: 10vmin; @@ -36,21 +38,26 @@ .next-leave-time { - width: 25%; - text-align: left + text-align: left; } .next-leave-route { - width: 25%; + border: 0.5vmin solid black; + border-radius: 100%; + padding: 8px; + min-width: 12vmin; + min-height: 12vmin; + text-align: center; + background: #ffd90f; } - .next-leave-destination + .next-leave-places { - width: 50%; + text-align: center; } - .via + .next-leave-places li { list-style: none; font-size: 6vmin; @@ -58,11 +65,6 @@ font-weight: normal; } - .next-leave-table - { - text-align: center; - } - #other-leaves { width: 100%; @@ -169,7 +171,6 @@ } } -