Browse Source

fix player qr_code

feature_tests
Burathar 5 years ago
parent
commit
858e440faa
  1. 12
      app/routes.py

12
app/routes.py

@ -125,16 +125,22 @@ def game_player(game_name, player_name):
@login_required @login_required
def player_qrcode(auth_hash): def player_qrcode(auth_hash):
player = Player.query.filter_by(auth_hash=auth_hash).first_or_404() player = Player.query.filter_by(auth_hash=auth_hash).first_or_404()
if not is_player_game_owner(player): #if not is_player_game_owner(player):
abort(403) # abort(403)
img = generate_qr_code(url_for('player', auth_hash=auth_hash, _external=True)) img = generate_qr_code(url_for('player', auth_hash=auth_hash, _external=True))
return serve_pil_image(img) return serve_pil_image(img)
@app.route('/player/<auth_hash>')
@login_required
def player(auth_hash):
player = Player.query.filter_by(auth_hash=auth_hash).first_or_404()
return render_template('player.html',title=f'Player: {player.name}', player=player)
def is_game_owner(game): def is_game_owner(game):
return current_user in [gameplayer.player for gameplayer in game.game_players if gameplayer.role == Role.owner] return current_user in [gameplayer.player for gameplayer in game.game_players if gameplayer.role == Role.owner]
def is_player_game_owner(player): def is_player_game_owner(player):
return current_user in [gameplayer.player for gameplayer in [game for game in player.games ].game_players if game_player.role == Role.owner] return current_user in [gameplayer.player for gameplayer in [game for game in player.games].game_players if game_player.role == Role.owner]
def is_objective_owner(objective): def is_objective_owner(objective):
return current_user in [gameplayer.player for gameplayer in objective.game.game_players if gameplayer.role == Role.owner] return current_user in [gameplayer.player for gameplayer in objective.game.game_players if gameplayer.role == Role.owner]

Loading…
Cancel
Save