diff --git a/agenda/__init__.py b/agenda/__init__.py
index 63b6e7d..80be7d2 100644
--- a/agenda/__init__.py
+++ b/agenda/__init__.py
@@ -22,12 +22,21 @@ def format_list_with_ampersand(items: list[str]) -> str:
return ""
+ESA = "AUT,BEL,CZE,DNK,FIN,FRA,DEU,GRC,IRE,ITA,LUZ,NLD,NOR,POL,PRT,ROU,ESP,SWE,CHE,GBR"
+
+
def get_country(alpha_2: str) -> pycountry.db.Country | None:
"""Lookup country by alpha-2 country code."""
+ if alpha_2 == ESA:
+ return pycountry.db.Country(flag="🇪🇺", name="ESA")
if not alpha_2:
return None
if alpha_2 == "xk":
return pycountry.db.Country(flag="\U0001F1FD\U0001F1F0", name="Kosovo")
- country: pycountry.db.Country = pycountry.countries.get(alpha_2=alpha_2.upper())
+ country: pycountry.db.Country
+ if len(alpha_2) == 2:
+ country = pycountry.countries.get(alpha_2=alpha_2.upper())
+ elif len(alpha_2) == 3:
+ country = pycountry.countries.get(alpha_3=alpha_2.upper())
return country
diff --git a/templates/launches.html b/templates/launches.html
index c048d5e..a4e718c 100644
--- a/templates/launches.html
+++ b/templates/launches.html
@@ -5,6 +5,7 @@
Space launches
{% for launch in rockets %}
+ {% set country = get_country(launch.country_code) %}
{{ launch.t0_date }}
@@ -17,7 +18,10 @@
launch status:
{{ launch.status.abbrev }}
-
{{ launch.rocket }}
+
+
+ {{ country.flag }}
+ {{ launch.rocket }}
–
{{launch.mission.name }}
–
@@ -30,14 +34,29 @@
({{ launch.launch_provider_type }})
—
{{ launch.orbit.name }} ({{ launch.orbit.abbrev }})
-
- {% if launch.pad_wikipedia_url %}
-
{{ launch.pad_name }}
- {% else %}
- {{ launch.pad_name }} {% if launch.pad_name != "Unknown Pad" %}(no Wikipedia article){% endif %}
+ —
+ {{ launch.mission.type }}
+
+
+ {% if launch.pad_wikipedia_url %}
+
{{ launch.pad_name }}
+ {% else %}
+ {{ launch.pad_name }} {% if launch.pad_name != "Unknown Pad" %}(no Wikipedia article){% endif %}
+ {% endif %}
+ — {{ launch.location }}
+
+ {% if launch.mission.agencies | count %}
+
+ agencies:
+ {% for agency in launch.mission.agencies %}
+ {%- if not loop.first %}, {% endif %}
+
{{agency.name }}
+ {{ get_country(agency.country_code).flag }}
+ ({{ agency.type }}) {#
#}
+ {% endfor %}
+
{% endif %}
- — {{ launch.location }}
-
+
{% if launch.mission %}
{% for line in launch.mission.description.splitlines() %}
{{ line }}
@@ -45,7 +64,7 @@
{% else %}
No description.
{% endif %}
-
+
{% endfor %}
diff --git a/web_view.py b/web_view.py
index f11fc68..2604353 100755
--- a/web_view.py
+++ b/web_view.py
@@ -74,7 +74,9 @@ async def launch_list() -> str:
rocket_dir = os.path.join(data_dir, "thespacedevs")
rockets = await agenda.thespacedevs.get_launches(rocket_dir, limit=100)
- return flask.render_template("launches.html", rockets=rockets, now=now)
+ return flask.render_template(
+ "launches.html", rockets=rockets, now=now, get_country=agenda.get_country
+ )
@app.route("/gaps")