|
|
@ -43,6 +43,10 @@ def add_player(game_name): |
|
|
|
def remove_player(game_name, username): |
|
|
|
def remove_player(game_name, username): |
|
|
|
game = get_game_if_owner(game_name) |
|
|
|
game = get_game_if_owner(game_name) |
|
|
|
user = User.query.filter(and_(User.name == username, User.games.contains(game))).first_or_404() |
|
|
|
user = User.query.filter(and_(User.name == username, User.games.contains(game))).first_or_404() |
|
|
|
|
|
|
|
if user.role_in_game(game) == Role.owner: |
|
|
|
|
|
|
|
if len([player for player in game.players if player.role == Role.owner]) < 2: |
|
|
|
|
|
|
|
flash("Can't remove only owner from game") |
|
|
|
|
|
|
|
return redirect(url_for('main.game_dashboard', game_name=game.name)) |
|
|
|
game.users.remove(user) |
|
|
|
game.users.remove(user) |
|
|
|
if not user.last_login: |
|
|
|
if not user.last_login: |
|
|
|
db.session.delete(user) |
|
|
|
db.session.delete(user) |
|
|
@ -69,7 +73,7 @@ def game_player(game_name, username): |
|
|
|
print(form.role.data) |
|
|
|
print(form.role.data) |
|
|
|
db.session.commit() |
|
|
|
db.session.commit() |
|
|
|
return redirect(url_for('main.game_dashboard', game_name=game.name)) |
|
|
|
return redirect(url_for('main.game_dashboard', game_name=game.name)) |
|
|
|
return render_template('game_player.html', title=f'{user.name} in {game_name}', |
|
|
|
return render_template('game_player.html', title=f'{user.name} in {game_name}', |
|
|
|
player=player, form=form, json=json, location_encoder=LocationEncoder) |
|
|
|
player=player, form=form, json=json, location_encoder=LocationEncoder) |
|
|
|
|
|
|
|
|
|
|
|
@bp.route('/game/<game_name>/catch_bunny', methods=['GET', 'POST']) |
|
|
|
@bp.route('/game/<game_name>/catch_bunny', methods=['GET', 'POST']) |
|
|
|