summaryrefslogtreecommitdiff
path: root/jfr_playoff/generator.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-02-21 14:09:05 +0100
committeremkael <emkael@tlen.pl>2018-02-21 14:09:05 +0100
commitccc54fde2f8c9301962e9c6f464d5f2eacd5506a (patch)
tree21a2f05ea664065d1aa98a3c69d58d6c14afdf59 /jfr_playoff/generator.py
parent415748f29a6b3048bef08703a93c4f441f67d1eb (diff)
Not rendering phase/match links if they're not set
Fixes #13
Diffstat (limited to 'jfr_playoff/generator.py')
-rw-r--r--jfr_playoff/generator.py35
1 files changed, 22 insertions, 13 deletions
diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py
index 49ae3a4..06234fb 100644
--- a/jfr_playoff/generator.py
+++ b/jfr_playoff/generator.py
@@ -33,24 +33,28 @@ class PlayoffGenerator(object):
def get_match_table(self, match):
rows = ''
for team in match.teams:
+ score_html = p_temp.MATCH_SCORE % (team.score)
+ team_label = ' / '.join([
+ self.data.get_shortname(name) for name in
+ team.name.split('<br />')])
+ team_html = p_temp.MATCH_TEAM_LINK % (
+ match.link, team.name, team_label) if match.link is not None \
+ else p_temp.MATCH_TEAM_NON_LINK % (
+ team.name, team_label)
rows += p_temp.MATCH_TEAM_ROW % (
' '.join([
'winner' if team.name == match.winner else '',
'loser' if team.name == match.loser else ''
]).strip(),
- match.link,
- team.name,
- ' / '.join([
- self.data.get_shortname(name) for name in
- team.name.split('<br />')]),
- match.link,
- team.score)
+ team_html,
+ p_temp.MATCH_LINK % (match.link, score_html) if match.link is not None else score_html)
html = p_temp.MATCH_TABLE.decode('utf8') % (
int(self.page['width'] * 0.75),
int(self.page['width'] * 0.25),
rows)
if match.running > 0:
- html += p_temp.MATCH_RUNNING % (match.link, match.running)
+ running_html = p_temp.MATCH_RUNNING % (match.running)
+ html += p_temp.MATCH_LINK % (match.link, running_html) if match.link is not None else running_html
return html
def get_phase_header(self, phase, position):
@@ -58,11 +62,16 @@ class PlayoffGenerator(object):
grid_header = p_temp.MATCH_GRID_PHASE_RUNNING
else:
grid_header = p_temp.MATCH_GRID_PHASE
- return grid_header % (
- phase.link,
- self.page['width'],
- position,
- phase.title)
+ grid_header = grid_header % (phase.title)
+ if phase.link is not None:
+ return p_temp.MATCH_GRID_PHASE_LINK % (
+ phase.link,
+ self.page['width'], position,
+ grid_header)
+ else:
+ return p_temp.MATCH_GRID_PHASE_NON_LINK % (
+ self.page['width'], position,
+ grid_header)
def get_match_box(self, match, position):
if match is not None: