Example #1
0
def _pull_user_id(endpoint, values):
    g.user_id = values.pop('user_id')

    g.pilots = get_requested_record_list(
        User, g.user_id, joinedload=[User.club])

    color_gen = color.generator()
    for pilot in g.pilots:
        pilot.color = color_gen.next()
Example #2
0
    def lookup(self, id, *remainder):
        # Fallback for old URLs
        if id == 'id' and len(remainder) > 0:
            id = remainder[0]
            remainder = remainder[1:]

        pilots = get_requested_record_list(User, id)
        controller = TrackController(pilots)
        return controller, remainder
Example #3
0
    def lookup(self, id, *remainder):
        # Fallback for old URLs
        if id == 'id' and len(remainder) > 0:
            id = remainder[0]
            remainder = remainder[1:]

        flights = get_requested_record_list(Flight, id)
        controller = FlightController(flights)
        return controller, remainder
Example #4
0
def _pull_flight_id(endpoint, values):
    g.flight_id = values.pop('flight_id')

    g.flights = get_requested_record_list(
        Flight, g.flight_id, joinedload=[Flight.igc_file])

    g.flight = g.flights[0]
    g.other_flights = g.flights[1:]

    map(_reanalyse_if_needed, g.flights)
Example #5
0
def _pull_user_id(endpoint, values):
    g.user_id = values.pop('user_id')

    g.pilots = get_requested_record_list(User,
                                         g.user_id,
                                         joinedload=[User.club])

    color_gen = color.generator()
    for pilot in g.pilots:
        pilot.color = color_gen.next()
Example #6
0
def _pull_flight_id(endpoint, values):
    g.flight_id = values.pop('flight_id')

    g.flights = get_requested_record_list(
        Flight, g.flight_id, joinedload=[Flight.igc_file])

    g.flight = g.flights[0]
    g.other_flights = g.flights[1:]

    map(_reanalyse_if_needed, g.flights)
Example #7
0
def _query_flights():
    g.flights = get_requested_record_list(
        Flight, g.flight_id, patch_query=_patch_query)

    g.flight = g.flights[0]
    g.other_flights = g.flights[1:]

    if not g.flight.is_viewable(None):
        g.logout_next = url_for('index')

    map(_reanalyse_if_needed, g.flights)
Example #8
0
def _query_flights():
    g.flights = get_requested_record_list(
        Flight, g.flight_id, patch_query=_patch_query)

    g.flight = g.flights[0]
    g.other_flights = g.flights[1:]

    if not g.flight.is_viewable(None):
        g.logout_next = url_for('index')

    map(_reanalyse_if_needed, g.flights)
Example #9
0
def read(user_ids):
    pilots = get_requested_record_list(User, user_ids, joinedload=[User.club])

    color_gen = color.generator()
    for pilot in pilots:
        pilot.color = next(color_gen)

    traces = list(map(_get_flight_path, pilots))
    if not any(traces):
        traces = None

    user_schema = UserSchema()

    pilots_json = []
    for pilot in pilots:
        json = user_schema.dump(pilot).data
        json["color"] = pilot.color
        pilots_json.append(json)

    flights = []
    if traces:
        for pilot, trace in zip(pilots, traces):
            if trace:
                flights.append(
                    {
                        "sfid": pilot.id,
                        "points": trace["points"],
                        "barogram_t": trace["barogram_t"],
                        "barogram_h": trace["barogram_h"],
                        "enl": trace["enl"],
                        "contests": None,
                        "elevations_t": trace["barogram_t"],
                        "elevations_h": trace["elevations"],
                        "geoid": trace["geoid"],
                        "additional": {
                            "competition_id": pilot.tracking_callsign
                            or pilot.initials(),
                            "color": pilot.color,
                        },
                    }
                )

    return jsonify(flights=flights, pilots=pilots_json)
Example #10
0
def read(user_ids):
    pilots = get_requested_record_list(User, user_ids, joinedload=[User.club])

    color_gen = color.generator()
    for pilot in pilots:
        pilot.color = color_gen.next()

    traces = map(_get_flight_path, pilots)
    if not any(traces):
        traces = None

    user_schema = UserSchema()

    pilots_json = []
    for pilot in pilots:
        json = user_schema.dump(pilot).data
        json['color'] = pilot.color
        pilots_json.append(json)

    flights = []
    if traces:
        for pilot, trace in zip(pilots, traces):
            if trace:
                flights.append({
                    'sfid': pilot.id,
                    'points': trace['points'],
                    'barogram_t': trace['barogram_t'],
                    'barogram_h': trace['barogram_h'],
                    'enl': trace['enl'],
                    'contests': None,
                    'elevations_t': trace['barogram_t'],
                    'elevations_h': trace['elevations'],
                    'geoid': trace['geoid'],
                    'additional': {
                        'competition_id':
                        pilot.tracking_callsign or pilot.initials(),
                        'color':
                        pilot.color,
                    },
                })

    return jsonify(flights=flights, pilots=pilots_json)
Example #11
0
def read(user_ids):
    pilots = get_requested_record_list(User, user_ids, joinedload=[User.club])

    color_gen = color.generator()
    for pilot in pilots:
        pilot.color = next(color_gen)

    traces = list(map(_get_flight_path, pilots))
    if not any(traces):
        traces = None

    user_schema = UserSchema()

    pilots_json = []
    for pilot in pilots:
        json = user_schema.dump(pilot).data
        json["color"] = pilot.color
        pilots_json.append(json)

    flights = []
    if traces:
        for pilot, trace in zip(pilots, traces):
            if trace:
                flights.append({
                    "sfid": pilot.id,
                    "points": trace["points"],
                    "barogram_t": trace["barogram_t"],
                    "barogram_h": trace["barogram_h"],
                    "enl": trace["enl"],
                    "contests": None,
                    "elevations_t": trace["barogram_t"],
                    "elevations_h": trace["elevations"],
                    "geoid": trace["geoid"],
                    "additional": {
                        "competition_id":
                        pilot.tracking_callsign or pilot.initials(),
                        "color":
                        pilot.color,
                    },
                })

    return jsonify(flights=flights, pilots=pilots_json)
Example #12
0
def read(user_ids):
    pilots = get_requested_record_list(User, user_ids, joinedload=[User.club])

    color_gen = color.generator()
    for pilot in pilots:
        pilot.color = color_gen.next()

    traces = map(_get_flight_path, pilots)
    if not any(traces):
        traces = None

    user_schema = UserSchema()

    pilots_json = []
    for pilot in pilots:
        json = user_schema.dump(pilot).data
        json['color'] = pilot.color
        pilots_json.append(json)

    flights = []
    if traces:
        for pilot, trace in zip(pilots, traces):
            if trace:
                flights.append({
                    'sfid': pilot.id,
                    'points': trace['points'],
                    'barogram_t': trace['barogram_t'],
                    'barogram_h': trace['barogram_h'],
                    'enl': trace['enl'],
                    'contests': None,
                    'elevations_t': trace['barogram_t'],
                    'elevations_h': trace['elevations'],
                    'geoid': trace['geoid'],
                    'additional': {
                        'competition_id': pilot.tracking_callsign or pilot.initials(),
                        'color': pilot.color,
                    },
                })

    return jsonify(flights=flights, pilots=pilots_json)
Example #13
0
 def _lookup(self, id, *remainder):
     pilots = get_requested_record_list(User, id)
     controller = TrackController(pilots)
     return controller, remainder
Example #14
0
 def _lookup(self, id, *remainder):
     flights = get_requested_record_list(Flight, id,
                                         joinedload=[Flight.igc_file])
     controller = FlightController(flights)
     return controller, remainder