]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Make the rank index titles data-driven.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 23 Jan 2016 15:40:50 +0000 (10:40 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 23 Jan 2016 15:40:50 +0000 (10:40 -0500)
xonstat/templates/rank_index.mako
xonstat/views/game.py

index c6ea4540426d2a4ec3e3f960f7127f0376a4dcb7..f1ad358b97d357b17e35c5f93d3b9968ef2ee4dd 100644 (file)
@@ -2,15 +2,7 @@
 <%namespace file="navlinks.mako" import="navlinks" />
 
 <%block name="title">
-  % if game_type_cd == 'dm':
-    Deathmatch Rank Index
-  % elif game_type_cd == 'duel':
-    Duel Rank Index
-  % elif game_type_cd == 'tdm':
-    Team Deathmatch Rank Index
-  % elif game_type_cd == 'ctf':
-    Capture The Flag Rank Index
-  % endif
+    ${game_type.descr} Rank Index
 </%block>
 
 <div class="row">
index b8b739c1315750ff10fa7bce2494ac3ca24ff94d..7af7c142957ac6b17ab40dc27e72bf19df8707b4 100644 (file)
@@ -116,10 +116,7 @@ def game_info_json(request):
 
 
 def _rank_index_data(request):
-    if request.params.has_key('page'):
-        current_page = request.params['page']
-    else:
-        current_page = 1
+    current_page = request.params.get("page", 1)
 
     # game type whitelist
     game_types_allowed = ["ca", "ctf", "dm", "duel", "ft", "ka", "tdm"]
@@ -132,6 +129,9 @@ def _rank_index_data(request):
             filter(PlayerRank.game_type_cd==game_type_cd).\
             order_by(PlayerRank.rank)
 
+    game_type = DBSession.query(GameType).\
+            filter(GameType.game_type_cd == game_type_cd).one()
+
     ranks = Page(ranks_q, current_page, url=page_url)
 
     if len(ranks) == 0:
@@ -140,6 +140,7 @@ def _rank_index_data(request):
     return {
             'ranks':ranks,
             'game_type_cd':game_type_cd,
+            'game_type': game_type,
            }