diff --git a/app/main/routes_player.py b/app/main/routes_player.py index 7620a58..40edccf 100644 --- a/app/main/routes_player.py +++ b/app/main/routes_player.py @@ -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))