Browse Source

show a warning and return when a player is added twice to a game

testing
Burathar 4 years ago
parent
commit
2098b80a7b
  1. 3
      app/main/routes_player.py

3
app/main/routes_player.py

@ -23,6 +23,9 @@ def add_player(game_name): @@ -23,6 +23,9 @@ def add_player(game_name):
if form_add.submit_add.data and form_add.validate_on_submit():
user = User.query.filter_by(name=form_add.name.data).first_or_404()
if user.player_in(game):
flash(f'{user.name} is already a player in this game!')
return redirect(url_for('main.game_dashboard', game_name=game.name))
game.players.append(GamePlayer(user=user, role=Role(form_add.role.data)))
db.session.commit()
return redirect(url_for('main.game_dashboard', game_name=game.name))

Loading…
Cancel
Save