Use get_country for Schengen report
This commit is contained in:
parent
f499015466
commit
f41930f811
|
|
@ -40,47 +40,6 @@ SCHENGEN_COUNTRIES = {
|
|||
"ch", # Switzerland
|
||||
}
|
||||
|
||||
# Country code to emoji flag mapping
|
||||
COUNTRY_FLAG_MAP = {
|
||||
"at": "🇦🇹", # Austria
|
||||
"be": "🇧🇪", # Belgium
|
||||
"bg": "🇧🇬", # Bulgaria
|
||||
"hr": "🇭🇷", # Croatia
|
||||
"cz": "🇨🇿", # Czech Republic
|
||||
"dk": "🇩🇰", # Denmark
|
||||
"ee": "🇪🇪", # Estonia
|
||||
"fi": "🇫🇮", # Finland
|
||||
"fr": "🇫🇷", # France
|
||||
"de": "🇩🇪", # Germany
|
||||
"gr": "🇬🇷", # Greece
|
||||
"hu": "🇭🇺", # Hungary
|
||||
"it": "🇮🇹", # Italy
|
||||
"lv": "🇱🇻", # Latvia
|
||||
"lt": "🇱🇹", # Lithuania
|
||||
"lu": "🇱🇺", # Luxembourg
|
||||
"mt": "🇲🇹", # Malta
|
||||
"nl": "🇳🇱", # Netherlands
|
||||
"pl": "🇵🇱", # Poland
|
||||
"pt": "🇵🇹", # Portugal
|
||||
"ro": "🇷🇴", # Romania
|
||||
"sk": "🇸🇰", # Slovakia
|
||||
"si": "🇸🇮", # Slovenia
|
||||
"es": "🇪🇸", # Spain
|
||||
"se": "🇸🇪", # Sweden
|
||||
"is": "🇮🇸", # Iceland
|
||||
"li": "🇱🇮", # Liechtenstein
|
||||
"no": "🇳🇴", # Norway
|
||||
"ch": "🇨🇭", # Switzerland
|
||||
}
|
||||
|
||||
|
||||
def get_country_flag(country_code: str) -> str:
|
||||
"""Get emoji flag for a country code."""
|
||||
if not country_code or not isinstance(country_code, str):
|
||||
return ""
|
||||
return COUNTRY_FLAG_MAP.get(country_code.lower(), "")
|
||||
|
||||
|
||||
def is_schengen_country(country_code: str) -> bool:
|
||||
"""Check if a country is in the Schengen area."""
|
||||
if not country_code or not isinstance(country_code, str):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from datetime import date, timedelta
|
|||
|
||||
import flask
|
||||
|
||||
from . import trip
|
||||
from . import get_country, trip
|
||||
from .schengen import calculate_schengen_time, extract_schengen_stays_from_travel
|
||||
from .types import SchengenCalculation, SchengenStay, StrDict, Trip
|
||||
|
||||
|
|
@ -181,7 +181,10 @@ def flask_route_schengen_report() -> str:
|
|||
trip_list = trip.build_trip_list(data_dir)
|
||||
|
||||
return flask.render_template(
|
||||
"schengen_report.html", trip_list=trip_list, **dashboard_data
|
||||
"schengen_report.html",
|
||||
trip_list=trip_list,
|
||||
get_country=get_country,
|
||||
**dashboard_data,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@
|
|||
<span class="text-muted">ongoing</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ stay.country | country_flag }} {{ stay.country.upper() }}</td>
|
||||
{% set country = get_country(stay.country) %}
|
||||
<td>{{ country.flag }} {{ country.name }}</td>
|
||||
<td>{{ stay.days }}</td>
|
||||
<td>
|
||||
{% if stay.trip_date and stay.trip_name %}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import agenda.trip
|
|||
import agenda.trip_schengen
|
||||
import agenda.utils
|
||||
from agenda import calendar, format_list_with_ampersand, travel, uk_tz
|
||||
from agenda.schengen import get_country_flag
|
||||
from agenda.types import StrDict, Trip
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
|
@ -38,12 +37,6 @@ app.config.from_object("config.default")
|
|||
agenda.error_mail.setup_error_mail(app)
|
||||
|
||||
|
||||
@app.template_filter("country_flag")
|
||||
def country_flag_filter(country_code: str) -> str:
|
||||
"""Convert country code to emoji flag."""
|
||||
return get_country_flag(country_code)
|
||||
|
||||
|
||||
@app.before_request
|
||||
def handle_auth() -> None:
|
||||
"""Handle authentication and set global user."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue