From 38dbb2b4e7fcd9578288d2456c03771bf4745902 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Thu, 9 Jul 2026 10:13:49 +0100 Subject: [PATCH] Add conference country filter --- templates/conference_list.html | 22 +++++++++ tests/test_conference_list.py | 82 ++++++++++++++++++++++++++++++++++ web_view.py | 75 ++++++++++++++++++++++++++++++- 3 files changed, 178 insertions(+), 1 deletion(-) diff --git a/templates/conference_list.html b/templates/conference_list.html index e20b154..70e5f10 100644 --- a/templates/conference_list.html +++ b/templates/conference_list.html @@ -212,6 +212,28 @@ tr.conf-hl > td {

Conferences

+ {% if country_options %} +
+
+ + +
+
+ + {% if selected_country %} + Clear + {% endif %} +
+
+ {% endif %} + {{ render_timeline(timeline) }} diff --git a/tests/test_conference_list.py b/tests/test_conference_list.py index 6eb26f7..d1ccc87 100644 --- a/tests/test_conference_list.py +++ b/tests/test_conference_list.py @@ -6,6 +6,7 @@ from types import SimpleNamespace import yaml +import agenda.fx import agenda.trip import web_view @@ -121,3 +122,84 @@ def test_conference_series_pages(tmp_path: typing.Any, monkeypatch: typing.Any) assert b"attended" in index_response.data assert detail_response.status_code == 200 assert b"trip: Seattle Python trip" in detail_response.data + + +def test_conference_page_filters_by_country( + tmp_path: typing.Any, monkeypatch: typing.Any +) -> None: + """Conference page should filter upcoming conferences by country code.""" + conferences = [ + { + "name": "UK Mapping Conf 2099", + "topic": "Maps", + "location": "London", + "country": "GB", + "start": date(2099, 5, 1), + "end": date(2099, 5, 2), + }, + { + "name": "US Python Conf 2099", + "topic": "Python", + "location": "Pittsburgh", + "country": "US", + "start": date(2099, 6, 1), + "end": date(2099, 6, 2), + }, + ] + (tmp_path / "conferences.yaml").write_text( + yaml.safe_dump(conferences), encoding="utf-8" + ) + + monkeypatch.setitem(web_view.app.config, "PERSONAL_DATA", str(tmp_path)) + monkeypatch.setattr(agenda.trip, "build_trip_list", lambda: []) + monkeypatch.setattr(agenda.fx, "get_rates", lambda config: {}) + + web_view.app.config["TESTING"] = True + with web_view.app.test_client() as client: + response = client.get("/conference?country=gb") + + assert response.status_code == 200 + assert b"UK Mapping Conf 2099" in response.data + assert b"US Python Conf 2099" not in response.data + assert b'