Example #1
0
def show_all_ships():
    sailing_ships = get_all_sailing_ships()
    for sailing_ship in sailing_ships:
        for crew_member in sailing_ship.crew:
            if current_user.get_id() == crew_member.sailor_id:
                sailing_ship.is_crew_member = True

    return render_template(
        "all_ships.html",
        sailing_ships=sailing_ships
    )
Example #2
0
def all_ships_json():
    ships = get_all_sailing_ships()
    return jsonify(
        ships=[
            {
                'id': ship.id,
                'captain_id': ship.captain_id,
                'destination': ship.destination,
                'time_created': str(ship.time_created),
                'departure_time': str(ship.departure_time),
                'crew': [c.sailor_id for c in ship.crew],
            } for ship in ships
        ],
    )