def players_statistics_search(): form = SearchForm(request.form) form.handle.choices = [ (player.id, player.handle) for player in Player.query.filter_by(account_id=current_user.id).all() ] if request.method == "GET": return render_template( "players/statisticsSearch.html", form=form, player_ranking=Player.player_ranking(id=current_user.id)) if request.method == "POST": if not form.handle.data: return render_template( "players/statisticsSearch.html", form=form, player_ranking=Player.player_ranking(id=current_user.id), error="Go create some stats first!") if not form.handle.choices: return render_template( "players/statisticsSearch.html", form=form, player_ranking=Player.player_ranking(id=current_user.id), error="Go create some stats first!") player = Player.query.filter_by(id=form.handle.data).first() return redirect(url_for("players_statisticsone", id=player.id)) return render_template( "players/statisticsSearch.html", form=form, player_ranking=Player.player_ranking(id=current_user.id))
def races_index(): races = Race.query.filter_by(account_id=current_user.id).all() for race in races: character = Character.query.filter_by(id=race.character_id).first() race.character = character.name track = Track.query.filter_by(id=race.track_id).first() race.track = track.name player = Player.query.filter_by(id=race.player_id).first() race.player = player.handle return render_template( "races/listraces.html", races=races, player_ranking=Player.player_ranking(id=current_user.id))