config.add_view(game_index, route_name="game_index", renderer="game_index.mako")
config.add_view(game_index_json, route_name="game_index_json", renderer="jsonp")
- config.add_route("game_index_filtered", "/games/{game_type_cd:\w+}")
- config.add_route("game_index_filtered_json", "/games/{game_type_cd:\w+}.json")
- config.add_view(game_index, route_name="game_index_filtered", renderer="game_index.mako")
- config.add_view(game_index_json, route_name="game_index_filtered_json", renderer="jsonp")
-
config.add_route("game_info", "/game/{id:\d+}")
config.add_route("game_info_json", "/game/{id:\d+}.json")
config.add_view(game_info, route_name="game_info", renderer="game_info.mako")
</%block>
% if not games:
- % if not game_type_cd:
-<h2>Sorry, no games yet. Get playing!</h2>
- % else:
-<h2>Sorry, no ${game_type_cd.upper()} games yet. Get playing!</h2>
+<h2>Sorry, no
+ % if game_type_descr:
+ ${game_type_descr}
% endif
+ games yet. Get playing!</h2>
% else:
<div class="row">
<div class="span12">
- % if not game_type_cd:
- <h2>Recent Games</h2>
- % else:
- <h2>Recent ${game_type_cd.upper()} Games</h2>
+ <h2>Recent
+ % if game_type_descr:
+ ${game_type_descr}
% endif
+ Games</h2>
</div>
</div>
<div class="row">
% if gt == 'overall':
<a href="${request.route_url("game_index")}" alt="${gt}" title="" data-toggle="none">
% else:
- <a href="${request.route_url("game_index_filtered", game_type_cd=gt)}" alt="${gt}" title="" data-toggle="none">
+ <a href="${request.route_url("game_index", _query={'game_type_cd':gt})}" alt="${gt}" title="" data-toggle="none">
% endif
<span class="sprite sprite-${gt}"> </span><br />
${gt} <br />
<div class="row">
<div class="span10 offset1">
<!-- navigation links -->
- ${navlinks("game_index", games.page, games.last_page)}
+ ${navlinks("game_index", games.page, games.last_page, search_query=request.GET)}
</div>
</div>
% endif
def _game_index_data(request):
- if request.matchdict.has_key('game_type_cd'):
- game_type_cd = request.matchdict['game_type_cd']
- else:
- game_type_cd = None
+ game_type_cd = None
+ game_type_descr = None
+
+ if request.params.has_key('game_type_cd'):
+ game_type_cd = request.params['game_type_cd']
+ try:
+ game_type_descr = DBSession.query(GameType.descr).\
+ filter(GameType.game_type_cd == game_type_cd).\
+ one()[0]
+ except Exception as e:
+ game_type_cd = None
if request.params.has_key('page'):
current_page = request.params['page']
else:
current_page = 1
-
+
try:
rgs_q = recent_games_q(game_type_cd=game_type_cd)
# replace the items in the canned pagination class with more rich ones
games.items = [RecentGame(row) for row in games.items]
-
+
pgstats = {}
for game in games.items:
pgstats[game.game_id] = DBSession.query(PlayerGameStat).\
filter(PlayerGameStat.game_id == game.game_id).\
order_by(PlayerGameStat.scoreboardpos).\
order_by(PlayerGameStat.score).all()
-
+
except Exception as e:
- games = None
- pgstats = None
- game_type_cd = None
+ games = None
+ pgstats = None
+ game_type_cd = None
+ game_type_descr = None
return {'games':games,
'pgstats':pgstats,
'game_type_cd':game_type_cd,
+ 'game_type_descr':game_type_descr,
}
pwstats[pgstat.player_game_stat_id] = []
# NOTE adding pgstat to position 6 in order to display nick.
- # You have to use a slice [0:5] to pass to the accuracy
+ # You have to use a slice [0:5] to pass to the accuracy
# template
- pwstats[pgstat.player_game_stat_id].append((weapon.descr,
- weapon.weapon_cd, pwstat.actual, pwstat.max,
+ pwstats[pgstat.player_game_stat_id].append((weapon.descr,
+ weapon.weapon_cd, pwstat.actual, pwstat.max,
pwstat.hit, pwstat.fired, pgstat))
except Exception as inst: