From ad74655978130bbdc7c915c5e82bb16daf0458bd Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Mon, 23 Feb 2015 18:19:44 -0500 Subject: [PATCH] Paginate differently on the game_finder page. --- xonstat/templates/game_finder.mako | 31 ++++++++++++++---------------- xonstat/views/game.py | 20 ++++++++++++++++++- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/xonstat/templates/game_finder.mako b/xonstat/templates/game_finder.mako index c74071b..ae3e2a3 100644 --- a/xonstat/templates/game_finder.mako +++ b/xonstat/templates/game_finder.mako @@ -15,27 +15,20 @@ ${nav.nav('games')} Game Index -% if len(recent_games) > 0: - ##### ROW OF GAME TYPE ICONS #####
@@ -46,6 +39,7 @@ Game Index ##### RECENT GAMES TABLE #####
+ % if len(recent_games) > 0: @@ -75,9 +69,13 @@ Game Index % endfor
+ % else: +

No more games to show!

+ % endif
+% if len(recent_games) == 20:
    @@ -87,5 +85,4 @@ Game Index
- % endif diff --git a/xonstat/views/game.py b/xonstat/views/game.py index b3d6038..b21497c 100644 --- a/xonstat/views/game.py +++ b/xonstat/views/game.py @@ -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): -- 2.39.2