return "<ActiveMap(%s, %s)>" % (self.sort_order, self.map_id)
+class PlayerMedal(object):
+ def __repr__(self):
+ return "<PlayerRank(pid=%s, place=%s, alt=%s)>" % (self.player_id,
+ self.place, self.alt)
+
+
def initialize_db(engine=None):
DBSession.configure(bind=engine)
Base.metadata.bind = engine
active_players_table = MetaData.tables['active_players_mv']
active_servers_table = MetaData.tables['active_servers_mv']
active_maps_table = MetaData.tables['active_maps_mv']
+ player_medals_table = MetaData.tables['player_medals']
# now map the tables and the objects together
mapper(PlayerAchievement, achievements_table)
mapper(ActivePlayer, active_players_table)
mapper(ActiveServer, active_servers_table)
mapper(ActiveMap, active_maps_table)
+ mapper(PlayerMedal, player_medals_table)
<div class="row">
<div class="small-12 columns">
- <h2> ${player.nick_html_colors()|n} </h2>
+ <h2>
+ ${player.nick_html_colors()|n}
+ % for medal in medals:
+ <img src="/static/medals/${medal.image}" alt="${medal.alt}" title="${medal.alt}" />
+ % endfor
+ </h2>
+
<h5>
<i><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">Joined ${player.joined_pretty_date()}</span> (player #${player.player_id})</i>
% if cake_day:
<img src="/static/images/icons/24x24/cake.png" title="Happy cake day!" />
% endif
</h5>
- <br />
</div>
</div>
return (avg, dmgs)
+def get_player_medals(player_id):
+ """Retrieves the list of medals the player has received from tournaments or
+ other contests."""
+ try:
+ medals = DBSession.query(PlayerMedal)\
+ .filter(PlayerMedal.player_id==player_id)\
+ .order_by(PlayerMedal.place)\
+ .order_by(PlayerMedal.create_dt)\
+ .all()
+
+ return medals
+
+ except Exception as e:
+ log.debug(e)
+ return []
+
+
def player_info_data(request):
player_id = int(request.matchdict['id'])
if player_id <= 2:
fav_maps = get_fav_maps(player_id)
elos = get_elos(player_id)
ranks = get_ranks(player_id)
+ medals = get_player_medals(player_id)
recent_games = get_recent_games(player_id)
cake_day = is_cake_day(player.create_dt)
'fav_maps':fav_maps,
'elos':elos,
'ranks':ranks,
+ 'medals':medals,
'recent_games':recent_games,
'cake_day':cake_day,
}