Move past conferences to separate page

Closes: #157
This commit is contained in:
Edward Betts 2024-06-15 20:56:37 +01:00
parent 964bbb1162
commit 882fa52ae5
2 changed files with 27 additions and 9 deletions

View file

@ -5,6 +5,7 @@
{"endpoint": "trip_future_list", "label": "Future trip" },
{"endpoint": "trip_past_list", "label": "Past trip" },
{"endpoint": "conference_list", "label": "Conference" },
{"endpoint": "past_conference_list", "label": "Past conference" },
{"endpoint": "travel_list", "label": "Travel" },
{"endpoint": "accommodation_list", "label": "Accommodation" },
{"endpoint": "gaps_page", "label": "Gap" },

View file

@ -24,7 +24,7 @@ import agenda.holidays
import agenda.thespacedevs
import agenda.trip
from agenda import format_list_with_ampersand, travel, uk_tz
from agenda.types import Trip
from agenda.types import StrDict, Trip
app = flask.Flask(__name__)
app.debug = False
@ -141,15 +141,13 @@ def as_date(d: date | datetime) -> date:
return d.date() if isinstance(d, datetime) else d
@app.route("/conference")
def conference_list() -> str:
"""Page showing a list of conferences."""
def build_conference_list() -> list[StrDict]:
"""Build conference list."""
data_dir = app.config["PERSONAL_DATA"]
filepath = os.path.join(data_dir, "conferences.yaml")
items = yaml.safe_load(open(filepath))
today = date.today()
items: list[StrDict] = yaml.safe_load(open(filepath))
conference_trip_lookup = {}
for trip in agenda.trip.build_trip_list():
for trip_conf in trip.conferences:
key = (trip_conf["start"], trip_conf["name"])
@ -168,8 +166,15 @@ def conference_list() -> str:
conf["linked_trip"] = this_trip
items.sort(key=operator.itemgetter("start_date"))
return items
@app.route("/conference")
def conference_list() -> str:
"""Page showing a list of conferences."""
today = date.today()
items = build_conference_list()
past = [conf for conf in items if conf["end_date"] < today]
current = [
conf
for conf in items
@ -180,7 +185,6 @@ def conference_list() -> str:
return flask.render_template(
"conference_list.html",
current=current,
past=past,
future=future,
today=today,
get_country=agenda.get_country,
@ -188,6 +192,19 @@ def conference_list() -> str:
)
@app.route("/conference/past")
def past_conference_list() -> str:
"""Page showing a list of conferences."""
today = date.today()
return flask.render_template(
"conference_list.html",
past=[conf for conf in build_conference_list() if conf["end_date"] < today],
today=today,
get_country=agenda.get_country,
fx_rate=agenda.fx.get_rates(app.config),
)
@app.route("/accommodation")
def accommodation_list() -> str:
"""Page showing a list of past, present and future accommodation."""