parent
fe4bde32ba
commit
a7296c943b
|
@ -133,6 +133,14 @@ class Trip:
|
|||
"""Countries flags for trip."""
|
||||
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
|
||||
class Holiday:
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<div class="heading"><h2>{{ heading }}</h2></div>
|
||||
<p>{{ items | count }} trips</p>
|
||||
{% for trip in items %}
|
||||
{% set total_distance = trip.total_distance() %}
|
||||
{% set end = trip.end %}
|
||||
<div class="border border-2 rounded mb-2 p-2">
|
||||
<h3>
|
||||
|
@ -63,6 +64,11 @@
|
|||
{% else %}
|
||||
<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>
|
||||
{% endif %}
|
||||
<div class="conferences">
|
||||
{% for conf in trip.conferences %}
|
||||
{{ conference_row(conf, "going") }}
|
||||
|
|
Loading…
Reference in a new issue