Add conference series pages
This commit is contained in:
parent
098c7e4447
commit
57b2db205d
9 changed files with 367 additions and 3 deletions
63
web_view.py
63
web_view.py
|
|
@ -372,6 +372,7 @@ def build_conference_list() -> list[StrDict]:
|
|||
data_dir = app.config["PERSONAL_DATA"]
|
||||
filepath = os.path.join(data_dir, "conferences.yaml")
|
||||
items: list[StrDict] = yaml.safe_load(open(filepath))
|
||||
series_lookup = agenda.conference.load_series(data_dir)
|
||||
conference_trip_lookup = {}
|
||||
|
||||
for trip in agenda.trip.build_trip_list():
|
||||
|
|
@ -386,6 +387,10 @@ def build_conference_list() -> list[StrDict]:
|
|||
if price:
|
||||
conf["price"] = decimal.Decimal(price)
|
||||
|
||||
series_id = conf.get("series")
|
||||
if isinstance(series_id, str):
|
||||
conf["series_detail"] = series_lookup.get(series_id)
|
||||
|
||||
if "start" in conf:
|
||||
key = (conf["start"], conf["name"])
|
||||
if this_trip := conference_trip_lookup.get(key):
|
||||
|
|
@ -395,6 +400,32 @@ def build_conference_list() -> list[StrDict]:
|
|||
return items
|
||||
|
||||
|
||||
def build_conference_series_list() -> list[StrDict]:
|
||||
"""Build conference series list with conference counts."""
|
||||
data_dir = app.config["PERSONAL_DATA"]
|
||||
series_lookup = agenda.conference.load_series(data_dir)
|
||||
conferences = build_conference_list()
|
||||
|
||||
series_items: list[StrDict] = []
|
||||
for series_id, series in series_lookup.items():
|
||||
linked = [conf for conf in conferences if conf.get("series") == series_id]
|
||||
latest = max((conf["sort_date"] for conf in linked), default=None)
|
||||
next_conf = next(
|
||||
(conf for conf in linked if conf["latest_date"] >= date.today()), None
|
||||
)
|
||||
item: StrDict = {
|
||||
"id": series_id,
|
||||
**series,
|
||||
"count": len(linked),
|
||||
"latest": latest,
|
||||
"next_conf": next_conf,
|
||||
}
|
||||
series_items.append(item)
|
||||
|
||||
series_items.sort(key=lambda item: str(item["name"]).lower())
|
||||
return series_items
|
||||
|
||||
|
||||
def _conference_uid(conf: StrDict) -> str:
|
||||
"""Generate deterministic UID for conference events."""
|
||||
start = agenda.utils.as_date(conf["start"])
|
||||
|
|
@ -596,6 +627,38 @@ def past_conference_list() -> str:
|
|||
)
|
||||
|
||||
|
||||
@app.route("/conference/series")
|
||||
def conference_series_list() -> str:
|
||||
"""Page showing conference series."""
|
||||
return flask.render_template(
|
||||
"conference_series_list.html",
|
||||
series_list=build_conference_series_list(),
|
||||
get_country=agenda.get_country,
|
||||
)
|
||||
|
||||
|
||||
@app.route("/conference/series/<series_id>")
|
||||
def conference_series_page(series_id: str) -> str:
|
||||
"""Page showing one conference series."""
|
||||
series_lookup = agenda.conference.load_series(app.config["PERSONAL_DATA"])
|
||||
series = series_lookup.get(series_id)
|
||||
if series is None:
|
||||
flask.abort(404)
|
||||
|
||||
conferences = [
|
||||
conf for conf in build_conference_list() if conf.get("series") == series_id
|
||||
]
|
||||
return flask.render_template(
|
||||
"conference_series.html",
|
||||
series_id=series_id,
|
||||
series=series,
|
||||
conferences=conferences,
|
||||
today=date.today(),
|
||||
get_country=agenda.get_country,
|
||||
fx_rate=agenda.fx.get_rates(app.config),
|
||||
)
|
||||
|
||||
|
||||
@app.route("/conference/ical")
|
||||
def conference_ical() -> werkzeug.Response:
|
||||
"""Return all conferences as an iCalendar feed."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue