def table_list_csv(): game_tables = db.get_all_game_tables() table_list_csv = StringIO() game_tables.to_list_csv(table_list_csv) resp = make_response(table_list_csv.getvalue()) resp.headers['Content-Type'] = 'text/csv' return resp
def test_get_all_game_tables(self): games = Games([ Game('1A', 'Game 1A', 'Author 1A', 'System 1A', 'Blurb 1A', 1, 2), Game('2A', 'Game 2A', 'Author 2A', 'System 2A', 'Blurb 2A', 1, 2), ]) players = Players([ Player('Gary Gygax', 'TSR', {'1A': 'G', '2A': 'G'}), Player('Dave Arneson', None, {'1A': 'P', '2A': 'P'}), ]) self.assertEqual([], db.get_game_tables('1A', games['1A'], players)) db.query_db( 'INSERT INTO game_tables (slot, data) VALUES (?, ?);', ('1A', '{"gm": "Gary Gygax", "players": ["Dave Arneson"]}')) db.query_db( 'INSERT INTO game_tables (slot, data) VALUES (?, ?);', ('2A', '{"gm": "Gary Gygax", "players": ["Dave Arneson"]}')) game_tables = db.get_all_game_tables(games, players) self.assertEqual(list(game_tables.all_tables()), [ GameTable(games['1A'], list(players)[0], list(players)[1:]), GameTable(games['2A'], list(players)[0], list(players)[1:]), ])
def tables(): game_tables = db.get_all_game_tables() return render_template( 'tables.html', game_tables=game_tables, player_name=player_name)