summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-04-25 12:44:27 +0200
committeremkael <emkael@tlen.pl>2018-04-25 12:44:27 +0200
commitb62a0aaa38a63e7ce769fc698da39b5b8c81849c (patch)
treecc9072ee225967534ee32ff166924b868604a47e
parent753085c46b30828092e66870f15763fee02b32f7 (diff)
Add config-specified classes to leaderboard positions
-rw-r--r--jfr_playoff/generator.py11
-rw-r--r--jfr_playoff/template.py2
2 files changed, 12 insertions, 1 deletions
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 = '''
-<tr>
+<tr class="%s">
<td class="bdc1">%d</td>
<td class="bd">
&nbsp;%s&nbsp;&nbsp;%s&nbsp;