From 3a7784bb255a176851cb9af6967dfe4273d5f7a3 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 16 Jan 2024 17:11:55 +0000 Subject: [PATCH] Show unbooked flights in orange Closes: #114 --- agenda/trip.py | 2 +- static/js/map.js | 4 ++-- web_view.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/agenda/trip.py b/agenda/trip.py index 4cf208a..bae4bb1 100644 --- a/agenda/trip.py +++ b/agenda/trip.py @@ -198,7 +198,7 @@ def get_trip_routes(trip: Trip) -> list[StrDict]: return [ { - "type": "flight", + "type": "unbooked_flight", "key": f'LHR_{item["location"]}_{item["country"]}', "from": lhr, "to": latlon_tuple(item), diff --git a/static/js/map.js b/static/js/map.js index 7410379..addc29a 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -39,14 +39,14 @@ function build_map(map_id, coordinates, routes) { // Draw routes routes.forEach(function(route) { - var color = {"train": "blue", "flight": "red"}[route.type]; + var color = {"train": "blue", "flight": "red", "unbooked_flight": "orange"}[route.type]; var style = { weight: 3, opacity: 0.5, color: color }; if (route.geojson) { // If route is defined as GeoJSON L.geoJSON(JSON.parse(route.geojson), { style: function(feature) { return style; } }).addTo(map); - } else if (route.type === "flight") { + } else if (route.type === "flight" || route.type === "unbooked_flight") { var flightPath = new L.Geodesic([[route.from, route.to]], style).addTo(map); } else { // If route is defined by 'from' and 'to' coordinates diff --git a/web_view.py b/web_view.py index 4efd49c..98a3b56 100755 --- a/web_view.py +++ b/web_view.py @@ -233,7 +233,7 @@ def trip_page(start: str) -> str: coordinates = agenda.trip.collect_trip_coordinates(trip) routes = agenda.trip.get_trip_routes(trip) - if any(route["type"] == "flight" for route in routes) and not any( + if any(route["type"] == "unbooked_flight" for route in routes) and not any( pin["type"] == "airport" for pin in coordinates ): airports = typing.cast(