Show prices for logged in users
Trip prices are visible on trip list, accommodation list, conference list and travel list. Prices are hidden if not logged in, except conference prices. Still need to show prices on individual trip page.
This commit is contained in:
parent
dbffd60937
commit
e2afe0ffa4
7 changed files with 53 additions and 7 deletions
11
web_view.py
11
web_view.py
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
"""Web page to show upcoming events."""
|
||||
|
||||
import decimal
|
||||
import inspect
|
||||
import operator
|
||||
import os.path
|
||||
|
|
@ -125,6 +126,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"])
|
||||
|
||||
for travel_type in flights, trains:
|
||||
for item in travel_type:
|
||||
price = item.get("price")
|
||||
if price:
|
||||
item["price"] = decimal.Decimal(price)
|
||||
|
||||
return flask.render_template("travel.html", flights=flights, trains=trains)
|
||||
|
||||
|
||||
|
|
@ -180,6 +187,10 @@ def accommodation_list() -> str:
|
|||
"""Page showing a list of past, present and future accommodation."""
|
||||
data_dir = app.config["PERSONAL_DATA"]
|
||||
items = travel.parse_yaml("accommodation", data_dir)
|
||||
for item in items:
|
||||
price = item.get("price")
|
||||
if price:
|
||||
item["price"] = decimal.Decimal(price)
|
||||
|
||||
stays_in_2024 = [item for item in items if item["from"].year == 2024]
|
||||
total_nights_2024 = sum(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue