Implement Schengen Area Compliance Report
How many close am I to 90 days in the last 180. Fixes #193.
This commit is contained in:
parent
084e5f44e3
commit
d2c4fa69ee
8 changed files with 866 additions and 1 deletions
25
web_view.py
25
web_view.py
|
|
@ -25,6 +25,7 @@ import agenda.holidays
|
|||
import agenda.stats
|
||||
import agenda.thespacedevs
|
||||
import agenda.trip
|
||||
import agenda.trip_schengen
|
||||
import agenda.utils
|
||||
from agenda import calendar, format_list_with_ampersand, travel, uk_tz
|
||||
from agenda.types import StrDict, Trip
|
||||
|
|
@ -36,6 +37,13 @@ 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."""
|
||||
from agenda.schengen import get_country_flag
|
||||
return get_country_flag(country_code)
|
||||
|
||||
|
||||
@app.before_request
|
||||
def handle_auth() -> None:
|
||||
"""Handle authentication and set global user."""
|
||||
|
|
@ -387,11 +395,17 @@ def get_trip_list(
|
|||
route_distances: agenda.travel.RouteDistances | None = None,
|
||||
) -> list[Trip]:
|
||||
"""Get list of trips respecting current authentication status."""
|
||||
return [
|
||||
trips = [
|
||||
trip
|
||||
for trip in agenda.trip.build_trip_list(route_distances=route_distances)
|
||||
if flask.g.user.is_authenticated or not trip.private
|
||||
]
|
||||
|
||||
# Add Schengen compliance information to each trip
|
||||
for trip in trips:
|
||||
agenda.trip_schengen.add_schengen_compliance_to_trip(trip)
|
||||
|
||||
return trips
|
||||
|
||||
|
||||
@app.route("/trip")
|
||||
|
|
@ -527,6 +541,9 @@ def trip_page(start: str) -> str:
|
|||
prev_trip, trip, next_trip = get_prev_current_and_next_trip(start, trip_list)
|
||||
if not trip:
|
||||
flask.abort(404)
|
||||
|
||||
# Add Schengen compliance information
|
||||
trip = agenda.trip_schengen.add_schengen_compliance_to_trip(trip)
|
||||
|
||||
coordinates = agenda.trip.collect_trip_coordinates(trip)
|
||||
routes = agenda.trip.get_trip_routes(trip, app.config["PERSONAL_DATA"])
|
||||
|
|
@ -603,6 +620,12 @@ def trip_stats() -> str:
|
|||
)
|
||||
|
||||
|
||||
@app.route("/schengen")
|
||||
def schengen_report() -> str:
|
||||
"""Schengen compliance report."""
|
||||
return agenda.trip_schengen.flask_route_schengen_report()
|
||||
|
||||
|
||||
@app.route("/callback")
|
||||
def auth_callback() -> tuple[str, int] | werkzeug.Response:
|
||||
"""Process the authentication callback."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue