diff --git a/agenda/conference.py b/agenda/conference.py index da697fe..c1939ea 100644 --- a/agenda/conference.py +++ b/agenda/conference.py @@ -18,6 +18,7 @@ class Conference: location: str start: date | datetime end: date | datetime + country: str | None = None venue: str | None = None address: str | None = None url: str | None = None diff --git a/templates/conference_list.html b/templates/conference_list.html index 5d490c1..b3422da 100644 --- a/templates/conference_list.html +++ b/templates/conference_list.html @@ -1,10 +1,11 @@ {% extends "base.html" %} {% block style %} +{% set column_count = 7 %} {% endblock %} {% macro row(item, badge) %} +{% set country = get_country(item.country) if item.country else None %}
{{ item.start.strftime("%a, %d %b %Y") }}
{{ item.end.strftime("%a, %d %b") }}
{{ item.name }} @@ -37,6 +39,17 @@
{{ item.topic }}
{{ item.location }}
+
+ {% if country %} + {{ country.flag }} {{ country.name }} + {% elif item.online %} + 💻 Online + {% else %} + + country code {{ item.country }} not found + + {% endif %} +
{{ item.url }}
{% endmacro %} diff --git a/web_view.py b/web_view.py index 041d9c2..4f07b43 100755 --- a/web_view.py +++ b/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,