Show country names and flags on conference page
This commit is contained in:
parent
fd46f0a405
commit
17036d849f
3 changed files with 29 additions and 6 deletions
17
web_view.py
17
web_view.py
|
|
@ -98,6 +98,13 @@ def as_date(d: date | datetime) -> date:
|
|||
return d.date() if isinstance(d, datetime) else d
|
||||
|
||||
|
||||
def get_country(alpha_2: str) -> str | None:
|
||||
"""Lookup country by alpha-2 country code."""
|
||||
if not alpha_2:
|
||||
return None
|
||||
return typing.cast(str, pycountry.countries.get(alpha_2=alpha_2.upper()))
|
||||
|
||||
|
||||
@app.route("/conference")
|
||||
def conference_list() -> str:
|
||||
"""Page showing a list of conferences."""
|
||||
|
|
@ -121,7 +128,12 @@ def conference_list() -> str:
|
|||
future = [conf for conf in item_list if conf["start_date"] > today]
|
||||
|
||||
return flask.render_template(
|
||||
"conference_list.html", current=current, past=past, future=future, today=today
|
||||
"conference_list.html",
|
||||
current=current,
|
||||
past=past,
|
||||
future=future,
|
||||
today=today,
|
||||
get_country=get_country,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -142,9 +154,6 @@ def accommodation_list() -> str:
|
|||
if stay["country"] != "gb"
|
||||
)
|
||||
|
||||
def get_country(alpha_2: str) -> str | None:
|
||||
return typing.cast(str | None, pycountry.countries.get(alpha_2=alpha_2.upper()))
|
||||
|
||||
return flask.render_template(
|
||||
"accommodation.html",
|
||||
items=items,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue