parent
21b67bdc64
commit
fd6d3b674b
2 changed files with 64 additions and 36 deletions
28
web_view.py
28
web_view.py
|
|
@ -164,9 +164,8 @@ def load_travel(travel_type: str) -> list[StrDict]:
|
|||
return items
|
||||
|
||||
|
||||
@app.route("/trip")
|
||||
def trip_list() -> str:
|
||||
"""Page showing a list of trips."""
|
||||
def build_trip_list() -> list[Trip]:
|
||||
"""Generate list of trips."""
|
||||
trips: dict[date, Trip] = {}
|
||||
|
||||
data_dir = app.config["PERSONAL_DATA"]
|
||||
|
|
@ -190,11 +189,30 @@ def trip_list() -> str:
|
|||
trips[start] = Trip(start=start)
|
||||
getattr(trips[start], key).append(item)
|
||||
|
||||
trip_list = [trip for _, trip in sorted(trips.items(), reverse=True)]
|
||||
return [trip for _, trip in sorted(trips.items())]
|
||||
|
||||
|
||||
@app.route("/trip")
|
||||
def trip_list() -> str:
|
||||
"""Page showing a list of trips."""
|
||||
trip_list = build_trip_list()
|
||||
|
||||
today = date.today()
|
||||
current = [
|
||||
item
|
||||
for item in trip_list
|
||||
if item.start <= today and (item.end or item.start) >= today
|
||||
]
|
||||
|
||||
past = [item for item in trip_list if (item.end or item.start) < today]
|
||||
future = [item for item in trip_list if item.start > today]
|
||||
|
||||
return flask.render_template(
|
||||
"trips.html",
|
||||
trips=trip_list,
|
||||
current=current,
|
||||
past=past,
|
||||
future=future,
|
||||
today=today,
|
||||
get_country=agenda.get_country,
|
||||
format_list_with_ampersand=format_list_with_ampersand,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue