Show distances on trip pages

Closes: #144
This commit is contained in:
Edward Betts 2024-04-06 16:13:07 +02:00
parent eb3be4cb51
commit 37be85593b

View file

@ -60,6 +60,7 @@
{% endblock %} {% endblock %}
{% set end = trip.end %} {% set end = trip.end %}
{% set total_distance = trip.total_distance() %}
{% block content %} {% block content %}
<div class="row"> <div class="row">
@ -80,6 +81,13 @@
{# <div>Countries: {{ trip.countries_str }}</div> #} {# <div>Countries: {{ trip.countries_str }}</div> #}
<div>Locations: {{ trip.locations_str }}</div> <div>Locations: {{ trip.locations_str }}</div>
{% if total_distance %}
<div>Total distance:
{{ "{:,.0f} km / {:,.0f} miles".format(total_distance, total_distance / 1.60934) }}
</div>
{% endif %}
{% set delta = human_readable_delta(trip.start) %} {% set delta = human_readable_delta(trip.start) %}
{% if delta %} {% if delta %}
<div>How long until trip: {{ delta }}</div> <div>How long until trip: {{ delta }}</div>
@ -201,11 +209,19 @@
{% if item.arrive %} {% if item.arrive %}
&rarr; &rarr;
{{ item.arrive.strftime("%H:%M %z") }} {{ item.arrive.strftime("%H:%M %z") }}
<span>🕒{{ ((item.arrive - item.depart).total_seconds() // 60) | int }} mins</span>
<span>{{ ((item.arrive - item.depart).total_seconds() // 60) | int }} mins</span>
{% endif %} {% endif %}
<span>{{ item.airline }}{{ item.flight_number }}</span> <span>{{ item.airline }}{{ item.flight_number }}</span>
{% if item.distance %}
<span>
🌍distance:
{{ "{:,.0f} km / {:,.0f} miles".format(item.distance, item.distance / 1.60934) }}
</span>
{% endif %}
</div> </div>
{% elif item.type == "train" %} {% elif item.type == "train" %}
<div> <div>
@ -215,7 +231,13 @@
{% if item.class %} {% if item.class %}
<span class="badge bg-info text-nowrap">{{ item.class }}</span> <span class="badge bg-info text-nowrap">{{ item.class }}</span>
{% endif %} {% endif %}
<span>{{ ((item.arrive - item.depart).total_seconds() // 60) | int }} mins</span> <span>🕒{{ ((item.arrive - item.depart).total_seconds() // 60) | int }} mins</span>
{% if item.distance %}
<span>
🛤️
{{ "{:,.0f} km / {:,.0f} miles".format(item.distance, item.distance / 1.60934) }}
</span>
{% endif %}
</div> </div>
{% endif %} {% endif %}
</p> </p>