def index(): near_flights = FlightMeetings.get_meetings(g.flight) mark_flight_notifications_read(g.flight) return render_template('flights/map.jinja', flight=g.flight, near_flights=near_flights, other_flights=g.other_flights, comments=comments_partial(), phase_formatter=format_phase, leg_formatter=format_legs)
def index(): near_flights = FlightMeetings.get_meetings(g.flight) mark_flight_notifications_read(g.flight) return render_template( 'flights/map.jinja', flight=g.flight, near_flights=near_flights, other_flights=g.other_flights, comments=comments_partial(), phase_formatter=format_phase, leg_formatter=format_legs)
def index(): def add_flight_path(flight): trace = _get_flight_path(flight) return (flight, trace) near_flights = FlightMeetings.get_meetings(g.flight) other_flights = map(add_flight_path, g.other_flights) mark_flight_notifications_read(g.flight) return render_template('flights/view.jinja', flight=g.flight, trace=_get_flight_path(g.flight), near_flights=near_flights, other_flights=other_flights, phase_formatter=format_phase)
def index(): def add_flight_path(flight): trace = _get_flight_path(flight) return (flight, trace) near_flights = FlightMeetings.get_meetings(g.flight) other_flights = map(add_flight_path, g.other_flights) mark_flight_notifications_read(g.flight) return render_template( 'flights/view.jinja', flight=g.flight, trace=_get_flight_path(g.flight), near_flights=near_flights, other_flights=other_flights, phase_formatter=format_phase)
def index(): if 'application/json' in request.headers.get('Accept', ''): return jsonify(flight=FlightSchema().dump(g.flight).data) near_flights = FlightMeetings.get_meetings(g.flight).values() near_flights = NearFlightSchema().dump(near_flights, many=True).data comments = FlightCommentSchema().dump(g.flight.comments, many=True).data phases_schema = FlightPhaseSchema(only=( 'circlingDirection', 'type', 'secondsOfDay', 'startTime', 'duration', 'altDiff', 'distance', 'vario', 'speed', 'glideRate', )) phases = phases_schema.dump(g.flight.phases, many=True).data cruise_performance_schema = FlightPhaseSchema(only=( 'duration', 'fraction', 'altDiff', 'distance', 'vario', 'speed', 'glideRate', 'count', )) cruise_performance = cruise_performance_schema.dump(g.flight.cruise_performance).data circling_performance_schema = FlightPhaseSchema(only=( 'circlingDirection', 'count', 'vario', 'fraction', 'duration', 'altDiff', )) circling_performance = circling_performance_schema.dump(g.flight.circling_performance, many=True).data contest_leg_schema = ContestLegSchema() contest_legs = {} for type in ['classic', 'triangle']: legs = g.flight.get_contest_legs('olc_plus', type) contest_legs[type] = contest_leg_schema.dump(legs, many=True).data mark_flight_notifications_read(g.flight) return render_template( 'flights/map.jinja', flight=g.flight, flight_json=FlightSchema().dump(g.flight).data, near_flights=near_flights, other_flights=g.other_flights, comments=comments, contest_legs=contest_legs, phases=phases, performance=dict(circling=circling_performance, cruise=cruise_performance))
def read(flight_id): flight = get_requested_record(Flight, flight_id, joinedload=[Flight.igc_file]) current_user = User.get(request.user_id) if request.user_id else None if not flight.is_viewable(current_user): return jsonify(), 404 _reanalyse_if_needed(flight) mark_flight_notifications_read(flight) flight_json = FlightSchema().dump(flight).data if 'extended' not in request.args: return jsonify(flight=flight_json) near_flights = FlightMeetings.get_meetings(flight).values() near_flights = NearFlightSchema().dump(near_flights, many=True).data comments = FlightCommentSchema().dump(flight.comments, many=True).data phases_schema = FlightPhaseSchema(only=( 'circlingDirection', 'type', 'secondsOfDay', 'startTime', 'duration', 'altDiff', 'distance', 'vario', 'speed', 'glideRate', )) phases = phases_schema.dump(flight.phases, many=True).data cruise_performance_schema = FlightPhaseSchema(only=( 'duration', 'fraction', 'altDiff', 'distance', 'vario', 'speed', 'glideRate', 'count', )) cruise_performance = cruise_performance_schema.dump( flight.cruise_performance).data circling_performance_schema = FlightPhaseSchema(only=( 'circlingDirection', 'count', 'vario', 'fraction', 'duration', 'altDiff', )) circling_performance = circling_performance_schema.dump( flight.circling_performance, many=True).data performance = dict(circling=circling_performance, cruise=cruise_performance) contest_leg_schema = ContestLegSchema() contest_legs = {} for type in ['classic', 'triangle']: legs = flight.get_contest_legs('olc_plus', type) contest_legs[type] = contest_leg_schema.dump(legs, many=True).data return jsonify(flight=flight_json, near_flights=near_flights, comments=comments, contest_legs=contest_legs, phases=phases, performance=performance)
def read(flight_id): flight = get_requested_record(Flight, flight_id, joinedload=[Flight.igc_file]) current_user = User.get(request.user_id) if request.user_id else None if not flight.is_viewable(current_user): return jsonify(), 404 _reanalyse_if_needed(flight) mark_flight_notifications_read(flight) flight_json = FlightSchema().dump(flight).data if "extended" not in request.args: return jsonify(flight=flight_json) near_flights = FlightMeetings.get_meetings(flight).values() near_flights = NearFlightSchema().dump(near_flights, many=True).data comments = FlightCommentSchema().dump(flight.comments, many=True).data phases_schema = FlightPhaseSchema( only=( "circlingDirection", "type", "secondsOfDay", "startTime", "duration", "altDiff", "distance", "vario", "speed", "glideRate", ) ) phases = phases_schema.dump(flight.phases, many=True).data cruise_performance_schema = FlightPhaseSchema( only=("duration", "fraction", "altDiff", "distance", "vario", "speed", "glideRate", "count") ) cruise_performance = cruise_performance_schema.dump(flight.cruise_performance).data circling_performance_schema = FlightPhaseSchema( only=("circlingDirection", "count", "vario", "fraction", "duration", "altDiff") ) circling_performance = circling_performance_schema.dump(flight.circling_performance, many=True).data performance = dict(circling=circling_performance, cruise=cruise_performance) contest_leg_schema = ContestLegSchema() contest_legs = {} for type in ["classic", "triangle"]: legs = flight.get_contest_legs("olc_plus", type) contest_legs[type] = contest_leg_schema.dump(legs, many=True).data return jsonify( flight=flight_json, near_flights=near_flights, comments=comments, contest_legs=contest_legs, phases=phases, performance=performance, )