]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Paginate differently on the game_finder page.
authorAnt Zucaro <azucaro@gmail.com>
Mon, 23 Feb 2015 23:19:44 +0000 (18:19 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Mon, 23 Feb 2015 23:19:44 +0000 (18:19 -0500)
xonstat/templates/game_finder.mako
xonstat/views/game.py

index c74071b47c83acd4ce62c7e1cab4e57fc1810d40..ae3e2a39085431458881266f818ebdc16fd2594e 100644 (file)
@@ -15,27 +15,20 @@ ${nav.nav('games')}
 Game Index
 </%block>
 
-% if len(recent_games) > 0:
-
 ##### ROW OF GAME TYPE ICONS #####
 <div class="row">
   <div class="span12 tabbable">
     <ul class="nav nav-tabs">
-      % for gt in ('overall','duel','ctf','dm','tdm','ca','kh','ft','lms','as','dom','nb','cts','rc'):
-      <li 
-      % if game_type_cd == gt or (game_type_cd is None and gt == 'overall'):
-      class="active"
-      % endif
+      % for gt, url in game_type_links:
+      <li
+        % if game_type_cd == gt or (game_type_cd is None and gt == 'overall'):
+        class="active"
+        % endif
       >
-
-      % if gt == 'overall':
-      <a href="${request.route_url("game_index")}" alt="${gt}" title="" data-toggle="none">
-      % else:
-      <a href="${request.route_url("game_index", _query={'type':gt})}" alt="${gt}" title="" data-toggle="none">
-      % endif
-        <span class="sprite sprite-${gt}"> </span><br />
-        ${gt} <br />
-      </a>
+        <a href="${url}" alt="${gt}" title="Show only ${gt} games" data-toggle="none">
+          <span class="sprite sprite-${gt}"> </span><br />
+          ${gt} <br />
+        </a>
       </li>
       % endfor
     </ul>
@@ -46,6 +39,7 @@ Game Index
 ##### RECENT GAMES TABLE #####
 <div class="row">
   <div class="span12">
+    % if len(recent_games) > 0:
     <table class="table table-hover table-condensed">
       <thead>
         <tr>
@@ -75,9 +69,13 @@ Game Index
         % endfor
         </tbody>
     </table>
+    % else:
+    <h2>No more games to show!</h2>
+    % endif
   </div> <!-- /span12 -->
 </div> <!-- /row -->
 
+% if len(recent_games) == 20:
 <div class="row">
   <div class="span12 text-center">
     <ul class="pagination">
@@ -87,5 +85,4 @@ Game Index
     </ul>
   </div>
 </div>
-
 % endif
index b3d6038b5ac358c0704b4332e57a5172d7ad4886..b21497cc65531f4e1426ce02c865b18c58bbfb29 100644 (file)
@@ -217,12 +217,30 @@ def game_finder_data(request):
 
     recent_games = [RecentGame(row) for row in rgs_q.limit(20).all()]
     
-    query['start_game_id'] = recent_games[-1].game_id + 1
+    if len(recent_games) > 0:
+        query['start_game_id'] = recent_games[-1].game_id + 1
+
+    # build the list of links for the stripe across the top
+    game_type_links = []
+
+    # clear out the game_id window
+    gt_query = query.copy()
+    if 'start_game_id' in gt_query:
+        del gt_query['start_game_id']
+    if 'end_game_id' in gt_query:
+        del gt_query['end_game_id']
+
+    for gt in ('overall','duel','ctf','dm','tdm','ca','kh','ft',
+            'lms','as','dom','nb','cts','rc'):
+        gt_query['type'] = gt
+        url = request.route_url("game_index", _query=gt_query)
+        game_type_links.append((gt, url))
 
     return {
             'recent_games':recent_games,
             'query':query,
             'game_type_cd':game_type_cd,
+            'game_type_links':game_type_links,
            }
 
 def game_finder(request):