From 733c80e37176692a5453b569adf0a3f519e44750 Mon Sep 17 00:00:00 2001 From: Burathar Date: Thu, 23 Jul 2020 11:49:41 +0200 Subject: [PATCH] fix create game game exists coding error, fix timepicker default value --- app/main/routes.py | 8 +++++--- app/templates/create_game.html | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/main/routes.py b/app/main/routes.py index 8c95ff4..b0089d3 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -39,11 +39,13 @@ def create_game(): form.state.choices = [(state.value, state.name) for state in GameState] if form.validate_on_submit(): - if Game.query.filter_by(name=form.game_name.data): + if Game.query.filter_by(name=form.game_name.data).first(): flash('Please choose a different game name') return render_template('create_game.html', title='Create Game', form=form) - game = Game(name=form.game_name.data, start_time=form.start_time.data, - end_time=form.end_time.data, state=GameState(form.state.data)) + game = Game(name=form.game_name.data, + start_time=form.start_time.data, + end_time=form.end_time.data, + state=GameState(form.state.data)) game.players.append(GamePlayer(user=current_user, role=Role['owner'])) db.session.add(game) db.session.commit() diff --git a/app/templates/create_game.html b/app/templates/create_game.html index d7d0d61..7443b30 100644 --- a/app/templates/create_game.html +++ b/app/templates/create_game.html @@ -55,13 +55,13 @@