]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Make latency displays parameter-driven.
authorAnt Zucaro <azucaro@gmail.com>
Wed, 23 Jan 2013 12:13:27 +0000 (07:13 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Wed, 23 Jan 2013 12:13:27 +0000 (07:13 -0500)
You can now use the show_latency query parameter to show ping
information in the scoreboards on the game_info page.

xonstat/templates/game_info.mako
xonstat/templates/scoreboard.mako
xonstat/views/game.py

index 678d612997e367c586bbc2f17132cc531d75a1eb..12f8c2306c8d39440ee06f539a8f37f635acb701 100644 (file)
@@ -49,7 +49,7 @@ Game Information
 <div class="row">
   <div class="span12 game">
     <h3>Scoreboard</h3>
-    ${scoreboard(game.game_type_cd, pgstats, show_elo)}
+    ${scoreboard(game.game_type_cd, pgstats, show_elo, show_latency)}
   </div>
 </div>
 
index 3304a951ef35d24355ab544078b7aa794101b373..ae58fbd0634e504deb9a06aff9d6622acc974aea 100644 (file)
@@ -1,6 +1,7 @@
-<%def name="scoreboard(game_type_cd, pgstats, show_elo=False)">
+<%def name="scoreboard(game_type_cd, pgstats, show_elo=False, show_latency=False)">
 <table  class="table table-bordered table-condensed">
 ${scoreboard_header(game_type_cd, pgstats[0])}
+${show_latency}
   <tbody>
   % for pgstat in pgstats:
     <tr class="${pgstat.team_html_color()}">
@@ -14,11 +15,11 @@ ${scoreboard_header(game_type_cd, pgstats[0])}
         <span class="nick">${pgstat.nick_html_colors()|n}</span>
       % endif
       </td>
-      % if pgstat.avg_latency is not None:
+      % if show_latency and pgstat.avg_latency is not None:
       <td>
         ${int(round(pgstat.avg_latency))}
       </td>
-      % else:
+      % elif show_latency:
       <td></td>
       % endif
       ${scoreboard_row(game_type_cd, pgstat)}
@@ -42,7 +43,7 @@ ${scoreboard_header(game_type_cd, pgstats[0])}
     <thead>
     <tr>
       <th class="nick">Nick</th>
-      % if pgstat.avg_latency is not None:
+      % if show_latency:
       <th class="ping">Ping</th>
       % endif
       <th class="kills">Kills</th>
@@ -60,7 +61,7 @@ ${scoreboard_header(game_type_cd, pgstats[0])}
     <thead class="ctf ${pgstat.team_html_color()}">
     <tr>
       <th class="nick">Nick</th>
-      % if pgstat.avg_latency is not None:
+      % if show_latency:
       <th class="ping">Ping</th>
       % endif
       <th class="kills">Kills</th>
@@ -80,7 +81,7 @@ ${scoreboard_header(game_type_cd, pgstats[0])}
     <thead class="ca ${pgstat.team_html_color()}">
     <tr>
       <th class="nick">Nick</th>
-      % if pgstat.avg_latency is not None:
+      % if show_latency:
       <th class="ping">Ping</th>
       % endif
       <th class="kills">Kills</th>
@@ -96,7 +97,7 @@ ${scoreboard_header(game_type_cd, pgstats[0])}
     <thead class="freezetag ${pgstat.team_html_color()}">
     <tr>
       <th class="nick">Nick</th>
-      % if pgstat.avg_latency is not None:
+      % if show_latency:
       <th class="ping">Ping</th>
       % endif
       <th class="kills">Kills</th>
index 2a7fbb56ad5cb2d7245532ffadb6e5792e166ac0..11be0287d0003312f4fd5175043383a657ca91cd 100644 (file)
@@ -62,6 +62,11 @@ def _game_info_data(request):
     else:
         show_elo = False
 
+    if request.params.has_key('show_latency'):
+        show_latency = True
+    else:
+        show_latency = False
+
     try:
         notfound = False
 
@@ -112,6 +117,7 @@ def _game_info_data(request):
         pwstats = None
         captimes = None
         show_elo = False
+        show_latency = False
         raise inst
 
     return {'game':game,
@@ -121,6 +127,7 @@ def _game_info_data(request):
             'pwstats':pwstats,
             'captimes':captimes,
             'show_elo':show_elo,
+            'show_latency':show_latency,
             }