Show country names and flags on accommodation page

This commit is contained in:
Edward Betts 2024-01-03 11:33:24 +00:00
parent 9800030201
commit fd46f0a405
2 changed files with 19 additions and 2 deletions

View file

@ -7,9 +7,11 @@ import operator
import os.path
import sys
import traceback
import typing
from datetime import date, datetime
import flask
import pycountry
import werkzeug
import werkzeug.debug.tbtools
import yaml
@ -140,11 +142,15 @@ 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,
total_nights_2024=total_nights_2024,
nights_abroad_2024=nights_abroad_2024,
get_country=get_country,
)