def highscores(request, page_number=1): """Show summary of all games (highscore table).""" highscore_iter = Game.highscore_queryset().iterator() scores = [(pos + 1, game) for pos, game in enumerate(highscore_iter)] paginator = Paginator(scores, 10) try: scores = paginator.page(page_number) except InvalidPage: scores = paginator.page(1) return render_to_response('quiz/highscores.html', { 'scores' : scores, })
def stats(request): """Show stats of the currently going (or finished) game.""" if 'game' not in request.session.keys(): return HttpResponseRedirect(reverse('musicquiz.quiz.views.index')) current_game = request.session['game'] score = current_game.total_score() highscore_iter = Game.highscore_queryset().iterator() fragment, pos = create_fragment(highscore_iter, current_game, 5) indexed_games = [(pos + i + 1, game) for i, game in enumerate(fragment)] return render_to_response('quiz/stats.html', { 'total_score' : score, 'this_game' : current_game, 'other_scores' : indexed_games, 'questions' : current_game.questions.all(), })