|
|
@ -39,11 +39,13 @@ def create_game(): |
|
|
|
form.state.choices = [(state.value, state.name) for state in GameState] |
|
|
|
form.state.choices = [(state.value, state.name) for state in GameState] |
|
|
|
|
|
|
|
|
|
|
|
if form.validate_on_submit(): |
|
|
|
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') |
|
|
|
flash('Please choose a different game name') |
|
|
|
return render_template('create_game.html', title='Create Game', form=form) |
|
|
|
return render_template('create_game.html', title='Create Game', form=form) |
|
|
|
game = Game(name=form.game_name.data, start_time=form.start_time.data, |
|
|
|
game = Game(name=form.game_name.data, |
|
|
|
end_time=form.end_time.data, state=GameState(form.state.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'])) |
|
|
|
game.players.append(GamePlayer(user=current_user, role=Role['owner'])) |
|
|
|
db.session.add(game) |
|
|
|
db.session.add(game) |
|
|
|
db.session.commit() |
|
|
|
db.session.commit() |
|
|
|