Beispiel #1
0
 def test_from_xls(self):
     xls_file = open(os.path.join(os.path.dirname(__file__), 'games.xls'))
     games = Games.from_xls(xls_file.read())
     self.assertEqual(list(games), [
         Game('1A', 'Game 1A', 'Author 1A', 'System 1A', 'Blurb 1A', 4, 6),
         Game('1B', 'Game 1B', 'Author 1B', 'System 1B', 'Blurb 1B', 5, 5),
     ])
Beispiel #2
0
def games_upload():
    f = request.files['games_file']
    if f.filename.endswith('.csv'):
        games = Games.from_csv(f)
    else:
        games = Games.from_xls(f.read())
    db.import_games(games, delete=True)
    flash("Games imported.")
    return redirect(url_for('games'))