parent
fe4bde32ba
commit
a7296c943b
|
@ -133,6 +133,14 @@ class Trip:
|
||||||
"""Countries flags for trip."""
|
"""Countries flags for trip."""
|
||||||
return "".join(c.flag for c in self.countries)
|
return "".join(c.flag for c in self.countries)
|
||||||
|
|
||||||
|
def total_distance(self) -> float | None:
|
||||||
|
"""Total distance for trip."""
|
||||||
|
return (
|
||||||
|
sum(t["distance"] for t in self.travel)
|
||||||
|
if all(t.get("distance") for t in self.travel)
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Holiday:
|
class Holiday:
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<div class="heading"><h2>{{ heading }}</h2></div>
|
<div class="heading"><h2>{{ heading }}</h2></div>
|
||||||
<p>{{ items | count }} trips</p>
|
<p>{{ items | count }} trips</p>
|
||||||
{% for trip in items %}
|
{% for trip in items %}
|
||||||
|
{% set total_distance = trip.total_distance() %}
|
||||||
{% set end = trip.end %}
|
{% set end = trip.end %}
|
||||||
<div class="border border-2 rounded mb-2 p-2">
|
<div class="border border-2 rounded mb-2 p-2">
|
||||||
<h3>
|
<h3>
|
||||||
|
@ -63,6 +64,11 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
|
<div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if total_distance %}
|
||||||
|
<div>Total distance:
|
||||||
|
{{ "{:,.0f} km / {:,.0f} miles".format(total_distance, total_distance / 1.60934) }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="conferences">
|
<div class="conferences">
|
||||||
{% for conf in trip.conferences %}
|
{% for conf in trip.conferences %}
|
||||||
{{ conference_row(conf, "going") }}
|
{{ conference_row(conf, "going") }}
|
||||||
|
|
Loading…
Reference in a new issue