From 2098b80a7bc11c0bf98c7ff2cfe2c4ab826229b2 Mon Sep 17 00:00:00 2001 From: Burathar Date: Wed, 19 Aug 2020 11:45:17 +0200 Subject: [PATCH] show a warning and return when a player is added twice to a game --- app/main/routes_player.py | 3 +++ 1 file changed, 3 insertions(+) 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))