Beispiel #1
0
 def test_get_players(self):
     self.assertEqual([], list(db.get_players()))
     db.import_players(Players([
         Player('Gary Gygax', 'TSR', {'1A': 'G'}),
         Player('Dave Arneson', None, {'1B': 'P'}),
     ]))
     players = db.get_players()
     self.assertTrue(isinstance(players, Players))
     self.assertEqual(list(players), [
         Player('Gary Gygax', 'TSR', {'1A': 'G'}),
         Player('Dave Arneson', None, {'1B': 'P'}),
     ])
Beispiel #2
0
def tables_upload():
    games = db.get_games()
    players = db.get_players()
    game_tables = GameTables.from_csv(
        games, players, request.files['tables.csv'])
    db.set_all_game_tables(game_tables)
    flash("Tables imported.")
    return redirect(url_for('tables'))
Beispiel #3
0
def players_csv():
    players = db.get_players()
    slots = players.get_slots()
    players_csv = StringIO()
    players.to_csv(slots, players_csv)
    resp = make_response(players_csv.getvalue())
    resp.headers['Content-Type'] = 'text/csv'
    return resp
Beispiel #4
0
def tables_generate_tables():
    players = db.get_players()
    games = db.get_games()
    generator = AllTablesGenerator(games, players)
    game_tables = generator.generate_lowest_penalty_tables()
    db.set_all_game_tables(game_tables)

    flash("Tables generated.")
    return redirect(url_for('tables'))
Beispiel #5
0
def players():
    slots = sorted(db.get_games().slots)
    players = db.get_players()
    player_only_slots = set(
        s for p in players for s in p.slots.keys() if s not in slots)
    if player_only_slots:
        flash("Warning: Players are registered for unknown slots: %s" % (
            ', '.join(sorted(player_only_slots)),), 'error')
        slots = sorted(slots + list(player_only_slots))
    return render_template('players.html', slots=slots, players=players)
Beispiel #6
0
 def assert_db_players(self, expected):
     with self.db_context():
         self.assertEqual(expected, list(db.get_players()))