Show distances for all past and future trips.

This commit is contained in:
Edward Betts 2024-05-27 10:16:03 +02:00
parent cd8dfb74a4
commit 38f2e10c6d
2 changed files with 51 additions and 6 deletions

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% from "macros.html" import trip_link, display_date_no_year, display_date, display_datetime, display_time with context %}
{% from "macros.html" import trip_link, display_date_no_year, display_date, display_datetime, display_time, format_distance with context %}
{% block title %}{{ heading }} - Edward Betts{% endblock %}
@ -52,6 +52,18 @@
{% set items = item_list | list %}
<div class="heading"><h2>{{ heading }}</h2></div>
<p>{{ items | count }} trips</p>
<div>Total distance: {{ format_distance(total_distance) }}</div>
{% for transport_type, distance in distances_by_transport_type %}
<div>
{{ transport_type | title }}
distance: {{format_distance(distance) }}
</div>
{% endfor %}
{% for trip in items %}
{% set distances_by_transport_type = trip.distances_by_transport_type() %}
{% set total_distance = trip.total_distance() %}
@ -74,15 +86,17 @@
<div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
{% endif %}
{% if total_distance %}
<div>Total distance:
{{ "{:,.0f} km / {:,.0f} miles".format(total_distance, total_distance / 1.60934) }}
<div>
Total distance:
{{ format_distance(total_distance) }}
</div>
{% endif %}
{% if distances_by_transport_type %}
{% for transport_type, distance in distances_by_transport_type %}
<div>{{ transport_type | title }} distance:
{{ "{:,.0f} km / {:,.0f} miles".format(distance, distance / 1.60934) }}
<div>
{{ transport_type | title }}
distance: {{format_distance(distance) }}
</div>
{% endfor %}
{% endif %}
@ -108,9 +122,14 @@
{% if e.element_type == "flight" %}
<span class="text-nowrap"><strong>airline:</strong> {{ e.detail.airline_name }}</span>
<span class="text-nowrap"><strong>flight number:</strong> {{ e.detail.airline }}{{ e.detail.flight_number }}</span>
<span class="text-nowrap"><strong>duration:</strong> {{ e.detail.duration }}</span>
{% if e.detail.duration %}
<span class="text-nowrap"><strong>duration:</strong> {{ e.detail.duration }}</span>
{% endif %}
{# <pre>{{ e.detail | pprint }}</pre> #}
{% endif %}
{% if e.detail.distance %}
<span class="text-nowrap"><strong>distance:</strong> {{ format_distance(e.detail.distance) }}</span>
{% endif %}
</div>
{% endif %}
{% endfor %}