Convert prices to GBP and show

Closes: #120
This commit is contained in:
Edward Betts 2024-04-20 07:54:16 +01:00
parent dbc12adb3d
commit 5ab9d93484
3 changed files with 32 additions and 6 deletions

View file

@ -2,6 +2,7 @@
"""Web page to show upcoming events."""
import decimal
import inspect
import operator
import os.path
@ -17,6 +18,7 @@ import yaml
import agenda.data
import agenda.error_mail
import agenda.fx
import agenda.holidays
import agenda.thespacedevs
import agenda.trip
@ -125,7 +127,12 @@ def travel_list() -> str:
if all("distance" in leg for leg in train["legs"]):
train["distance"] = sum(leg["distance"] for leg in train["legs"])
return flask.render_template("travel.html", flights=flights, trains=trains)
return flask.render_template(
"travel.html",
flights=flights,
trains=trains,
fx_rate=agenda.fx.get_rates(app.config),
)
def as_date(d: date | datetime) -> date:
@ -151,6 +158,10 @@ def conference_list() -> str:
conf["start_date"] = as_date(conf["start"])
conf["end_date"] = as_date(conf["end"])
price = conf.get("price")
if price:
conf["price"] = decimal.Decimal(price)
key = (conf["start"], conf["name"])
if this_trip := conference_trip_lookup.get(key):
conf["linked_trip"] = this_trip
@ -172,6 +183,7 @@ def conference_list() -> str:
future=future,
today=today,
get_country=agenda.get_country,
fx_rate=agenda.fx.get_rates(app.config),
)
@ -218,6 +230,7 @@ def accommodation_list() -> str:
total_nights_2024=total_nights_2024,
nights_abroad_2024=nights_abroad_2024,
get_country=agenda.get_country,
fx_rate=agenda.fx.get_rates(app.config),
)
@ -263,6 +276,7 @@ def trip_list() -> str:
today=today,
get_country=agenda.get_country,
format_list_with_ampersand=format_list_with_ampersand,
fx_rate=agenda.fx.get_rates(app.config),
)