diff --git a/templates/trip_debug.html b/templates/trip_debug.html new file mode 100644 index 0000000..7ccc06e --- /dev/null +++ b/templates/trip_debug.html @@ -0,0 +1,128 @@ +{% extends "base.html" %} + +{% block title %}Debug: {{ trip.title }} ({{ trip.start }}) - Edward Betts{% endblock %} + +{% block style %} + +{% endblock %} + +{% block content %} +
+
+

🐛 Trip Debug Information

+

Raw trip object data for: {{ trip.title }}

+ ← Back to Trip Page + +
+ +
+
+

Trip Object (JSON)

+
{{ trip_json }}
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/web_view.py b/web_view.py index 2cffe28..3a23807 100755 --- a/web_view.py +++ b/web_view.py @@ -4,8 +4,10 @@ import decimal import inspect +import json import operator import os.path +import pprint import sys import time import traceback @@ -586,6 +588,62 @@ def trip_page(start: str) -> str: ) +@app.route("/trip//debug") +def trip_debug_page(start: str) -> str: + """Trip debug page showing raw trip object data.""" + route_distances = agenda.travel.load_route_distances(app.config["DATA_DIR"]) + trip_list = get_trip_list(route_distances) + + 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) + + # Convert trip object to dictionary for display + trip_dict = { + "start": trip.start.isoformat(), + "name": trip.name, + "private": trip.private, + "travel": trip.travel, + "accommodation": trip.accommodation, + "conferences": trip.conferences, + "events": trip.events, + "flight_bookings": trip.flight_bookings, + "computed_properties": { + "title": trip.title, + "end": trip.end.isoformat() if trip.end else None, + "countries": [{"name": c.name, "alpha_2": c.alpha_2, "flag": c.flag} for c in trip.countries], + "locations": [{"location": loc, "country": {"name": country.name, "alpha_2": country.alpha_2}} for loc, country in trip.locations()], + "total_distance": trip.total_distance(), + "total_co2_kg": trip.total_co2_kg(), + "distances_by_transport_type": trip.distances_by_transport_type(), + "co2_by_transport_type": trip.co2_by_transport_type(), + }, + "schengen_compliance": { + "total_days_used": trip.schengen_compliance.total_days_used, + "days_remaining": trip.schengen_compliance.days_remaining, + "is_compliant": trip.schengen_compliance.is_compliant, + "current_180_day_period": [ + trip.schengen_compliance.current_180_day_period[0].isoformat(), + trip.schengen_compliance.current_180_day_period[1].isoformat() + ], + "days_over_limit": trip.schengen_compliance.days_over_limit, + } if trip.schengen_compliance else None, + } + + # Convert to JSON for pretty printing + trip_json = json.dumps(trip_dict, indent=2, default=str) + + return flask.render_template( + "trip_debug.html", + trip=trip, + trip_json=trip_json, + start=start, + ) + + @app.route("/holidays") def holiday_list() -> str: """List of holidays."""