summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-08-01 02:35:02 +0200
committeremkael <emkael@tlen.pl>2017-08-01 02:35:02 +0200
commit904f476b1cb17f83a369e1b03440b00809535fc1 (patch)
tree2fbe54afaaabeab0093abdce0be041be8f6ff3a4 /jfr_playoff
parent8e470272fea69a26c7d860c20433c9a0007f0b2e (diff)
Playoff phase is now also stored as DTO, arbitrary setting reads factored out of content generator
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/data.py9
-rw-r--r--jfr_playoff/dto.py7
-rw-r--r--jfr_playoff/generator.py14
3 files changed, 19 insertions, 11 deletions
diff --git a/jfr_playoff/data.py b/jfr_playoff/data.py
index 6c3f0ed..2a965d1 100644
--- a/jfr_playoff/data.py
+++ b/jfr_playoff/data.py
@@ -19,15 +19,18 @@ class PlayoffData(object):
phase_count = len(phase['matches'])
if 'dummies' in phase:
phase_count += len(phase['dummies'])
- phase_grid = [None] * phase_count
+ phase_object = Phase()
+ phase_object.title = phase['title']
+ phase_object.link = phase['link']
+ phase_object.matches = [None] * phase_count
phase_pos = 0
for match in phase['matches']:
if 'dummies' in phase:
while phase_pos in phase['dummies']:
phase_pos += 1
- phase_grid[phase_pos] = match['id']
+ phase_object.matches[phase_pos] = match['id']
phase_pos += 1
- grid.append(phase_grid)
+ grid.append(phase_object)
return grid
def fill_match_info(self):
diff --git a/jfr_playoff/dto.py b/jfr_playoff/dto.py
index d34b01d..9a72a12 100644
--- a/jfr_playoff/dto.py
+++ b/jfr_playoff/dto.py
@@ -11,4 +11,9 @@ class Match(object):
winner_matches = None
loser_matches = None
-__all__ = ['Team', 'Match']
+class Phase(object):
+ title = None
+ link = None
+ matches = []
+
+__all__ = ['Team', 'Match', 'Phase']
diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py
index 80405cd..81ca6c9 100644
--- a/jfr_playoff/generator.py
+++ b/jfr_playoff/generator.py
@@ -55,21 +55,21 @@ class PlayoffGenerator(object):
) - self.page['margin']
grid_boxes = ''
col_no = 0
- for column in grid:
+ for phase in grid:
grid_x = col_no * (self.page['width'] + self.page['margin'])
grid_header = p_temp.MATCH_GRID_PHASE_RUNNING if len([
- match for match in column if match is not None and matches[match].running > 0
+ match for match in phase.matches if match is not None and matches[match].running > 0
]) > 0 else p_temp.MATCH_GRID_PHASE
grid_boxes += grid_header % (
- self.settings.get('phases', col_no, 'link'),
+ phase.link,
self.page['width'],
grid_x,
- self.settings.get('phases', col_no, 'title')
+ phase.title
)
row_no = 0
- column_height = grid_height / len(column)
- for match in column:
- grid_y = int(row_no * column_height + 0.5 * (column_height - self.page['height']))
+ match_height = grid_height / len(phase.matches)
+ for match in phase.matches:
+ grid_y = int(row_no * match_height + 0.5 * (match_height - self.page['height']))
if match is not None:
grid_boxes += p_temp.MATCH_BOX % (
grid_x, grid_y,