diff --git a/leaderboard/templates/home.html b/leaderboard/templates/home.html
index 3519d78..8dbc343 100644
--- a/leaderboard/templates/home.html
+++ b/leaderboard/templates/home.html
@@ -46,21 +46,38 @@
PongBoard
PPG |
AvgDiff |
- {% for ranking in leaderboard %}
+ {% for ranked_player in ranked_players %}
{{ forloop.counter }} |
- {{ ranking.player.full_name }} |
- {{ ranking.rating }} |
- {{ ranking.games_played }} |
- {{ ranking.wins }} |
- {{ ranking.losses }} |
- {{ ranking.win_percent|percentage:1 }} |
- {{ ranking.points_per_game|floatformat }} |
- {{ ranking.avg_point_differential|stringformat:"+.1f" }} |
+ {{ ranked_player.player.full_name }} |
+ {{ ranked_player.rating }} |
+ {{ ranked_player.games_played }} |
+ {{ ranked_player.wins }} |
+ {{ ranked_player.losses }} |
+ {{ ranked_player.win_percent|percentage:1 }} |
+ {{ ranked_player.points_per_game|floatformat }} |
+ {{ ranked_player.avg_point_differential|stringformat:"+.1f" }} |
+
+ {% endfor %}
+ {% for unranked_player in unranked_players %}
+
+ N/A |
+ {{ unranked_player.player.full_name }} |
+ {{ unranked_player.rating }} |
+ {{ unranked_player.games_played }} |
+ {{ unranked_player.wins }} |
+ {{ unranked_player.losses }} |
+ {{ unranked_player.win_percent|percentage:1 }} |
+ {{ unranked_player.points_per_game|floatformat }} |
+ {{ unranked_player.avg_point_differential|stringformat:"+.1f" }} |
{% endfor %}
+ {% if unranked_players %}
+ Note: you must play a minimum of 5 games before being ranked.
+ {% endif %}
+
{% for match in recent_matches %}
- {{ match.description }}
diff --git a/leaderboard/views.py b/leaderboard/views.py
index 71f9494..3c7da7d 100644
--- a/leaderboard/views.py
+++ b/leaderboard/views.py
@@ -7,7 +7,9 @@
def home_page(request):
"""Render view for home page."""
recent_matches = Match.get_recent_matches(num_matches=20)
- leaderboard = PlayerRating.objects.all().order_by('-rating')
+ rated_players = PlayerRating.objects.all().order_by('-rating')
+ ranked_players = [player for player in rated_players if player.games_played >= 5]
+ unranked_players = [player for player in rated_players if player.games_played < 5]
match_form = MatchForm()
player_form = PlayerForm()
if request.method == 'POST':
@@ -28,6 +30,7 @@ def home_page(request):
'recent_matches': recent_matches,
'match_form': match_form,
'player_form': player_form,
- 'leaderboard': leaderboard
+ 'ranked_players': ranked_players,
+ 'unranked_players': unranked_players
}
)