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 @@