Compare commits

..

2 commits

4 changed files with 110 additions and 3 deletions

View file

@ -23,7 +23,6 @@ from . import (
conference, conference,
domains, domains,
economist, economist,
fx,
gwr, gwr,
hn, hn,
holidays, holidays,
@ -337,7 +336,6 @@ async def get_data(
t0 = time() t0 = time()
result_list = await asyncio.gather( result_list = await asyncio.gather(
time_function("gbpusd", fx.get_gbpusd, config),
time_function("gwr_advance_tickets", gwr.advance_ticket_date, data_dir), time_function("gwr_advance_tickets", gwr.advance_ticket_date, data_dir),
time_function("backwell_bins", waste_collection_events, data_dir), time_function("backwell_bins", waste_collection_events, data_dir),
time_function("bristol_bins", bristol_waste_collection_events, data_dir, today), time_function("bristol_bins", bristol_waste_collection_events, data_dir, today),
@ -356,7 +354,6 @@ async def get_data(
reply: dict[str, typing.Any] = { reply: dict[str, typing.Any] = {
"now": now, "now": now,
"gbpusd": results["gbpusd"],
"stock_markets": stock_market_times, "stock_markets": stock_market_times,
"rockets": rockets, "rockets": rockets,
"gwr_advance_tickets": gwr_advance_tickets, "gwr_advance_tickets": gwr_advance_tickets,

View file

@ -66,6 +66,25 @@ class Trip:
max_date = max(max_conference_end, travel_end, accommodation_end) max_date = max(max_conference_end, travel_end, accommodation_end)
return max_date if max_date != datetime.date.min else None return max_date if max_date != datetime.date.min else None
def locations(self) -> list[tuple[str, Country]]:
"""Locations for trip."""
seen: set[tuple[str, str]] = set()
items = []
for item in self.conferences + self.accommodation + self.events:
if "country" not in item or "location" not in item:
continue
key = (item["location"], item["country"])
if key in seen:
continue
seen.add(key)
country = agenda.get_country(item["country"])
assert country
items.append((item["location"], country))
return items
@property @property
def countries(self) -> list[Country]: def countries(self) -> list[Country]:
"""Countries visited as part of trip, in order.""" """Countries visited as part of trip, in order."""
@ -90,6 +109,13 @@ class Trip:
[f"{c.flag} {c.name}" for c in self.countries] [f"{c.flag} {c.name}" for c in self.countries]
) )
@property
def locations_str(self) -> str:
"""List of countries visited on this trip."""
return format_list_with_ampersand(
[f"{location} {c.flag}" for location, c in self.locations()]
)
@property @property
def country_flags(self) -> str: def country_flags(self) -> str:
"""Countries flags for trip.""" """Countries flags for trip."""

View file

@ -0,0 +1,67 @@
{% extends "base.html" %}
{% from "macros.html" import trip_link, display_date_no_year, display_date, conference_row, accommodation_row, flight_row, train_row with context %}
{% set row = { "flight": flight_row, "train": train_row } %}
{% block style %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""/>
{% set conference_column_count = 7 %}
{% set accommodation_column_count = 7 %}
{% set travel_column_count = 8 %}
<style>
.conferences {
display: grid;
grid-template-columns: repeat({{ conference_column_count }}, auto); /* 7 columns for each piece of information */
gap: 10px;
justify-content: start;
}
.accommodation {
display: grid;
grid-template-columns: repeat({{ accommodation_column_count }}, auto);
gap: 10px;
justify-content: start;
}
.travel {
display: grid;
grid-template-columns: repeat({{ travel_column_count }}, auto);
gap: 10px;
justify-content: start;
}
.grid-item {
/* Additional styling for grid items can go here */
}
.map {
height: 80vh;
}
</style>
{% endblock %}
{% block content %}
<div class="p-2">
<h1>Trips</h1>
<p>{{ future | count }} trips</p>
{% for trip in future %}
{% set end = trip.end %}
<div>
{{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}:
{{ trip.title }} &mdash; {{ trip.locations_str }}
</div>
{% endfor %}
</div>
{% endblock %}

View file

@ -220,6 +220,23 @@ def trip_list() -> str:
) )
@app.route("/trip/text")
def trip_list_text() -> str:
"""Page showing a list of trips."""
trip_list = agenda.trip.build_trip_list()
today = date.today()
future = [item for item in trip_list if item.start > today]
return flask.render_template(
"trip_list_text.html",
future=future,
today=today,
get_country=agenda.get_country,
format_list_with_ampersand=format_list_with_ampersand,
)
def human_readable_delta(future_date: date) -> str | None: def human_readable_delta(future_date: date) -> str | None:
""" """
Calculate the human-readable time delta for a given future date. Calculate the human-readable time delta for a given future date.