diff options
author | emkael <emkael@tlen.pl> | 2017-10-21 18:05:13 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-10-21 18:05:13 +0200 |
commit | 54729ff05267ffddaff919dfbdc3b13d8767cd5e (patch) | |
tree | 8ac0ef909a93c1f287842d65f4a25fb0fa05db63 /jfr_playoff | |
parent | 928e70491d957142afc4f4d948de563556053f93 (diff) |
Ability to set custom link label for swiss tournament links
Diffstat (limited to 'jfr_playoff')
-rw-r--r-- | jfr_playoff/data.py | 3 | ||||
-rw-r--r-- | jfr_playoff/generator.py | 13 | ||||
-rw-r--r-- | jfr_playoff/template.py | 4 |
3 files changed, 14 insertions, 6 deletions
diff --git a/jfr_playoff/data.py b/jfr_playoff/data.py index 47d66f5..5599fe5 100644 --- a/jfr_playoff/data.py +++ b/jfr_playoff/data.py @@ -231,7 +231,8 @@ class PlayoffData(object): def get_swiss_info(self): return [{ 'link': self.get_swiss_link(event), - 'position': event['position'] + 'position': event['position'], + 'label': event['label'] if 'label' in event else None } for event in self.swiss] def get_dimensions(self): diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 479f33b..bb18bb9 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -124,10 +124,15 @@ class PlayoffGenerator(object): return html def get_swiss_links(self): - return '\n'.join([ - p_temp.SWISS_LINK % ( - event['link'], event['position'] - ) for event in self.data.get_swiss_info()]) + info = [] + for event in self.data.get_swiss_info(): + event_label = p_temp.SWISS_DEFAULT_LABEL % (event['position']) + if 'label' in event and event['label'] is not None: + event_label = event['label'] + info.append(p_temp.SWISS_LINK % ( + event['link'], event_label + )) + return '\n'.join(info) def get_flag(self, team): flag = self.data.get_team_image(team) diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py index 63d4cdf..3296461 100644 --- a/jfr_playoff/template.py +++ b/jfr_playoff/template.py @@ -131,5 +131,7 @@ PAGE = ''' ''' SWISS_LINK = ''' -[<a href="%s" class="zb" target="_top"> Turniej o %d. miejsce </a>]<br /><br /> +[<a href="%s" class="zb" target="_top"> %s </a>]<br /><br /> ''' + +SWISS_DEFAULT_LABEL = 'Turniej o %d. miejsce' |