diff options
author | emkael <emkael@tlen.pl> | 2017-02-22 15:53:55 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-02-22 15:53:55 +0100 |
commit | f5b982e2aab612f3a8d7325f714792a670a348f6 (patch) | |
tree | db02ab2a2e76cf95885a6fc4de6d719362634bb9 | |
parent | ef06b88555ee46c9dd199f83dce731d8a7b039a6 (diff) |
Leaderboard fixes, regarding team flags
-rw-r--r-- | playoff.py | 18 | ||||
-rw-r--r-- | playoff/template.py | 18 |
2 files changed, 28 insertions, 8 deletions
@@ -28,6 +28,12 @@ def get_shortname(fullname): return team[1] return fullname +def get_team_image(fullname): + for team in settings['teams']: + if team[0] == fullname and len(team) > 2: + return p_temp.LEADERBOARD_ROW_FLAG % (team[2]) + return '' + def get_match_table(match): rows = '' for team in match.teams: @@ -75,10 +81,12 @@ def get_match_grid(grid, matches, width, height): return p_temp.MATCH_GRID % (width, height, width, height, grid_boxes) def get_leaderboard_table(leaderboard): + if len([t for t in leaderboard if t is not None]) == 0: + return '' position = 1 rows = '' - for team in [team if team is not None else '' for team in leaderboard]: - rows += p_temp.LEADERBOARD_ROW % (position, team) + for team in leaderboard: + rows += p_temp.LEADERBOARD_ROW % (position, get_team_image(team), team or '') position +=1 html = p_temp.LEADERBOARD.decode('utf8') % (rows) return html @@ -112,7 +120,7 @@ def get_match_info(match): info.loser_matches = list(set(info.loser_matches)) try: row = db_fetch(match['database'], p_sql.PREFIX, ()) - info.link = '%srunda%d' % (row[0], match['round']) + info.link = '%srunda%d.html' % (row[0], match['round']) except Exception as e: pass try: @@ -166,6 +174,10 @@ for phase in settings['phases']: match_info[match['id']].link = phase['link'] if match_info[match['id']].link is None else urljoin(phase['link'], match_info[match['id']].link) grid[-1].append(match['id']) +for team in settings['teams']: + if len(team) > 3: + leaderboard[team[3]-1] = team[0] + leaderboard_teams = {} for phase in settings['phases']: for match in phase['matches']: diff --git a/playoff/template.py b/playoff/template.py index 65a846b..5a282e3 100644 --- a/playoff/template.py +++ b/playoff/template.py @@ -38,19 +38,21 @@ MATCH_GRID = ''' ''' MATCH_GRID_PHASE = ''' -<a href="%s" target="_top" style="display: inline-block; width: %dpx; text-align: center; position: absolute; top: 0; left: %dpx">%s</a> +<a href="%s" target="_top" style="display: inline-block; width: %dpx; text-align: center; position: absolute; top: 0; left: %dpx"> +<font size="4">%s</font> +</a> ''' -MATCH_GRID_RUNNING_PHASE = ''' +MATCH_GRID_PHASE_RUNNING = ''' <a href="%s" target="_top" style="display: inline-block; width: %dpx; text-align: center; position: absolute; top: 0; left: %dpx"> <img src="images/A.gif" /> -%s +<font size="4">%s</font> <img src="images/A.gif" /> </a> ''' MATCH_BOX = ''' -<div style="position: absolute; left: %dpx; top: %dpx" data-id="%d" data-winner="%s" data-loser="%s" class="playoff_matchbox"> +<div style="text-align: center; position: absolute; left: %dpx; top: %dpx" data-id="%d" data-winner="%s" data-loser="%s" class="playoff_matchbox"> %s </div> ''' @@ -74,10 +76,16 @@ LEADERBOARD = ''' LEADERBOARD_ROW = ''' <tr> <td class="bdc1">%d</td> -<td class="bd"> %s </td> +<td class="bd"> + %s %s +</td> </tr> ''' +LEADERBOARD_ROW_FLAG = ''' +<img class="fl" src="images/%s" /> +''' + PAGE_HEAD = ''' <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Cache-Control" content="no-cache" /> |