summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-04-25 12:44:58 +0200
committeremkael <emkael@tlen.pl>2018-04-25 12:44:58 +0200
commit2b00cc4735293a5276d120529a0bcc3b95177219 (patch)
treeb18a6d3e99279c2e9f8c069f91bb81faadea6173
parentb62a0aaa38a63e7ce769fc698da39b5b8c81849c (diff)
Add explanation of leaderboard classes for these with defined captions
-rw-r--r--jfr_playoff/generator.py21
-rw-r--r--jfr_playoff/template.py17
2 files changed, 33 insertions, 5 deletions
diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py
index 5ce7d4d..2b5aaf0 100644
--- a/jfr_playoff/generator.py
+++ b/jfr_playoff/generator.py
@@ -16,6 +16,11 @@ class PlayoffGenerator(object):
self.leaderboard_classes = settings.get('position_styles')
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 % (
@@ -24,12 +29,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'))))
@@ -129,6 +132,14 @@ class PlayoffGenerator(object):
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:
diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py
index 6e412b9..b99c7c7 100644
--- a/jfr_playoff/template.py
+++ b/jfr_playoff/template.py
@@ -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">&nbsp;</td></tr>
+<tr><td class="bdnl12" align="center"><b>&nbsp;LEGENDA&nbsp;</b></td></tr>
+%s
+</table>
+'''
+
+LEADERBOARD_CAPTION_TABLE_ROW = '''
+<tr class="%s">
+<td class="bd1">
+&nbsp;%s&nbsp;
+</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 = '''