diff options
author | emkael <emkael@tlen.pl> | 2018-04-25 13:13:55 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2018-04-25 13:13:55 +0200 |
commit | 3352b2986b8d0c941eec01fdad13b2fac9cc4418 (patch) | |
tree | aee570abe83aa91235f77ebc45c03dfc15f4b6ae /jfr_playoff | |
parent | 13a2d2e230b39efe4d06b80c667b0fbabae83239 (diff) | |
parent | 1060632734b1f4e1117cbc33163101999ab201f6 (diff) |
Merge branch 'position-styles' into devel
Diffstat (limited to 'jfr_playoff')
-rw-r--r-- | jfr_playoff/generator.py | 34 | ||||
-rw-r--r-- | jfr_playoff/template.py | 19 |
2 files changed, 47 insertions, 6 deletions
diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 97624a2..ee1a496 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -16,8 +16,18 @@ class PlayoffGenerator(object): self.canvas = settings.get('canvas') PlayoffLogger.get('generator').info( 'canvas settings: %s', self.canvas) + self.leaderboard_classes = {} + if settings.has_section('position_styles'): + self.leaderboard_classes = settings.get('position_styles') + PlayoffLogger.get('generator').info( + 'leaderboard classes settings: %s', self.leaderboard_classes) def generate_content(self): + match_grid = self.get_match_grid( + self.data.get_dimensions(), + self.data.generate_phases(), + self.data.fill_match_info()) + leaderboard_table = self.get_leaderboard_table() return p_temp.PAGE % ( p_temp.PAGE_HEAD % ( p_temp.PAGE_HEAD_REFRESH % ( @@ -26,12 +36,10 @@ class PlayoffGenerator(object): self.page['title']), p_temp.PAGE_BODY % ( self.page['logoh'], - self.get_match_grid( - self.data.get_dimensions(), - self.data.generate_phases(), - self.data.fill_match_info()), + match_grid, self.get_swiss_links(), - self.get_leaderboard_table(), + leaderboard_table, + self.get_leaderboard_caption_table() if leaderboard_table else '', p_temp.PAGE_BODY_FOOTER.decode('utf8') % ( datetime.now().strftime('%Y-%m-%d o %H:%M:%S')))) @@ -131,6 +139,21 @@ class PlayoffGenerator(object): grid_boxes ) + def get_leaderboard_row_class(self, position): + classes = [] + for style in self.leaderboard_classes: + if position in style['positions']: + classes.append(style['class']) + return ' '.join(classes) + + def get_leaderboard_caption_table(self): + rows = '' + for style in self.leaderboard_classes: + if 'caption' in style: + rows += p_temp.LEADERBOARD_CAPTION_TABLE_ROW % ( + style['class'], style['caption']) + return p_temp.LEADERBOARD_CAPTION_TABLE % (rows) if rows else '' + def get_leaderboard_table(self): leaderboard = self.data.fill_leaderboard() if len([t for t in leaderboard if t is not None]) == 0: @@ -139,6 +162,7 @@ class PlayoffGenerator(object): rows = '' for team in leaderboard: rows += p_temp.LEADERBOARD_ROW % ( + self.get_leaderboard_row_class(position), position, self.get_flag(team), team or '') position += 1 html = p_temp.LEADERBOARD.decode('utf8') % (rows) diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py index e9ba977..b99c7c7 100644 --- a/jfr_playoff/template.py +++ b/jfr_playoff/template.py @@ -96,7 +96,7 @@ LEADERBOARD = ''' ''' LEADERBOARD_ROW = ''' -<tr> +<tr class="%s"> <td class="bdc1">%d</td> <td class="bd"> %s %s @@ -108,6 +108,22 @@ LEADERBOARD_ROW_FLAG = ''' <img class="fl" src="images/%s" /> ''' +LEADERBOARD_CAPTION_TABLE = ''' +<table class="caption_table" border="0" cellspacing="0"> +<tr><td class="e"> </td></tr> +<tr><td class="bdnl12" align="center"><b> LEGENDA </b></td></tr> +%s +</table> +''' + +LEADERBOARD_CAPTION_TABLE_ROW = ''' +<tr class="%s"> +<td class="bd1"> + %s +</td> +</tr> +''' + PAGE_HEAD = ''' <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Cache-Control" content="no-cache" /> @@ -134,6 +150,7 @@ PAGE_BODY = ''' </p> %s %s +%s ''' PAGE_BODY_FOOTER = ''' |