From b62a0aaa38a63e7ce769fc698da39b5b8c81849c Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 25 Apr 2018 12:44:27 +0200 Subject: Add config-specified classes to leaderboard positions --- jfr_playoff/generator.py | 11 +++++++++++ jfr_playoff/template.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'jfr_playoff') diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index cc4469d..5ce7d4d 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -11,6 +11,9 @@ class PlayoffGenerator(object): self.canvas = {} if settings.has_section('canvas'): self.canvas = settings.get('canvas') + self.leaderboard_classes = {} + if settings.has_section('position_styles'): + self.leaderboard_classes = settings.get('position_styles') def generate_content(self): return p_temp.PAGE % ( @@ -119,6 +122,13 @@ 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_table(self): leaderboard = self.data.fill_leaderboard() if len([t for t in leaderboard if t is not None]) == 0: @@ -127,6 +137,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..6e412b9 100644 --- a/jfr_playoff/template.py +++ b/jfr_playoff/template.py @@ -96,7 +96,7 @@ LEADERBOARD = ''' ''' LEADERBOARD_ROW = ''' - + %d  %s  %s  -- cgit v1.2.3