Fix flightradar24 URL to use IATA code over ICAO

Fixes #165
This commit is contained in:
Edward Betts 2025-07-21 07:34:47 +02:00
parent e6327780aa
commit 72940be3d2

View file

@ -96,6 +96,10 @@
</div> </div>
{% endmacro %} {% endmacro %}
{% macro flightradar24_url(flight) -%}
https://www.flightradar24.com/data/flights/{{ flight.airline_detail.iata | lower + flight.flight_number }}
{%- endmacro %}
{% macro flight_booking_row(booking, show_flags=True) %} {% macro flight_booking_row(booking, show_flags=True) %}
<div class="grid-item"> <div class="grid-item">
{% if g.user.is_authenticated %} {% if g.user.is_authenticated %}
@ -134,8 +138,8 @@
<div class="grid-item">{{ item.duration }}</div> <div class="grid-item">{{ item.duration }}</div>
<div class="grid-item">{{ full_flight_number }}</div> <div class="grid-item">{{ full_flight_number }}</div>
<div class="grid-item"> <div class="grid-item">
<a href="https://www.flightradar24.com/data/flights/{{ full_flight_number | lower }}">flightradar24</a> <a href="{{ flightradar24_url(item) }}">flightradar24</a>
| <a href="https://uk.flightaware.com/live/flight/{{ full_flight_number | replace("U2", "EZY") }}">FlightAware</a> | <a href="https://uk.flightaware.com/live/flight/{{ full_flight_number }}">FlightAware</a>
| <a href="{{ radarbox_url }}">radarbox</a> | <a href="{{ radarbox_url }}">radarbox</a>
</div> </div>
<div class="grid-item text-end"> <div class="grid-item text-end">
@ -169,8 +173,8 @@
{% endif %} {% endif %}
</div> </div>
<div class="grid-item"> <div class="grid-item">
<a href="https://www.flightradar24.com/data/flights/{{ full_flight_number | lower }}">flightradar24</a> <a href="{{ flightradar24_url(item) }}">flightradar24</a>
| <a href="https://uk.flightaware.com/live/flight/{{ full_flight_number | replace("U2", "EZY") }}">FlightAware</a> | <a href="https://uk.flightaware.com/live/flight/{{ full_flight_number }}">FlightAware</a>
| <a href="{{ radarbox_url }}">radarbox</a> | <a href="{{ radarbox_url }}">radarbox</a>
</div> </div>
<div class="grid-item text-end"> <div class="grid-item text-end">
@ -402,21 +406,22 @@
&ndash; &ndash;
{{ e.end_loc }} {{ flag(trip, e.end_country.flag) }} {{ e.end_loc }} {{ flag(trip, e.end_country.flag) }}
{% if e.element_type == "flight" %} {% if e.element_type == "flight" %}
{% set full_flight_number = e.detail.airline_code + e.detail.flight_number %} {% set flight = e.detail %}
{% set full_flight_number = flight.airline_code + flight.flight_number %}
{% set radarbox_url = "https://www.radarbox.com/data/flights/" + full_flight_number %} {% set radarbox_url = "https://www.radarbox.com/data/flights/" + full_flight_number %}
<span class="text-nowrap"><strong>airline:</strong> {{ e.detail.airline_name }}</span> <span class="text-nowrap"><strong>airline:</strong> {{ flight.airline_name }}</span>
<span class="text-nowrap"><strong>flight number:</strong> {{ full_flight_number }}</span> <span class="text-nowrap"><strong>flight number:</strong> {{ full_flight_number }}</span>
{% if e.detail.duration %} {% if flight.duration %}
<span class="text-nowrap"><strong>duration:</strong> {{ e.detail.duration }}</span> <span class="text-nowrap"><strong>duration:</strong> {{ flight.duration }}</span>
{% endif %} {% endif %}
{# <pre>{{ e.detail | pprint }}</pre> #} {# <pre>{{ flight | pprint }}</pre> #}
<span class="text-nowrap"><strong>CO₂:</strong> {{ "{:,.1f}".format(e.detail.co2_kg) }} kg</span> <span class="text-nowrap"><strong>CO₂:</strong> {{ "{:,.1f}".format(flight.co2_kg) }} kg</span>
{% endif %} {% endif %}
{% if e.detail.distance %} {% if e.detail.distance %}
<span class="text-nowrap"><strong>distance:</strong> {{ format_distance(e.detail.distance) }}</span> <span class="text-nowrap"><strong>distance:</strong> {{ format_distance(e.detail.distance) }}</span>
{% endif %} {% endif %}
{% if e.element_type == "flight" %} {% if e.element_type == "flight" %}
<a href="https://www.flightradar24.com/data/flights/{{ full_flight_number | lower }}">flightradar24</a> <a href="{{ flightradar24_url(flight) }}">flightradar24</a>
| <a href="https://uk.flightaware.com/live/flight/{{ full_flight_number }}">FlightAware</a> | <a href="https://uk.flightaware.com/live/flight/{{ full_flight_number }}">FlightAware</a>
| <a href="{{ radarbox_url }}">radarbox</a> | <a href="{{ radarbox_url }}">radarbox</a>
{% endif %} {% endif %}