summaryrefslogtreecommitdiff
path: root/playoff.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-02-22 14:40:52 +0100
committeremkael <emkael@tlen.pl>2017-02-22 14:40:52 +0100
commitef06b88555ee46c9dd199f83dce731d8a7b039a6 (patch)
tree2ac61237d635ff5e3eb2f2d5c71449ed537d804e /playoff.py
parentf118c0f3704fa07a33543ee2aa018f16ac993b5a (diff)
Fetching prefixes for match links
Diffstat (limited to 'playoff.py')
-rw-r--r--playoff.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/playoff.py b/playoff.py
index e2243d8..0e7cce5 100644
--- a/playoff.py
+++ b/playoff.py
@@ -1,6 +1,7 @@
import json, os, shutil, sys
import mysql.connector
from datetime import datetime
+from urlparse import urljoin
from playoff import sql as p_sql
from playoff import template as p_temp
@@ -31,8 +32,10 @@ def get_match_table(match):
rows = ''
for team in match.teams:
rows += p_temp.MATCH_TEAM_ROW % (
+ match.link,
team.name,
' / '.join([get_shortname(name) for name in team.name.split('<br />')]),
+ match.link,
team.score
)
html = p_temp.MATCH_TABLE.decode('utf8') % (
@@ -87,7 +90,7 @@ class Team:
class Match:
teams = None
running = 0
- link = '#'
+ link = None
winner = None
loser = None
winner_matches = None
@@ -108,6 +111,11 @@ def get_match_info(match):
info.winner_matches = list(set(info.winner_matches))
info.loser_matches = list(set(info.loser_matches))
try:
+ row = db_fetch(match['database'], p_sql.PREFIX, ())
+ info.link = '%srunda%d' % (row[0], match['round'])
+ except Exception as e:
+ pass
+ try:
row = db_fetch(match['database'], p_sql.MATCH_RESULTS, (match['table'], match['round']))
info.teams[0].name = row[0]
info.teams[1].name = row[1]
@@ -155,7 +163,7 @@ for phase in settings['phases']:
grid.append([])
for match in phase['matches']:
match_info[match['id']] = get_match_info(match)
- match_info[match['id']].link = phase['link']
+ match_info[match['id']].link = phase['link'] if match_info[match['id']].link is None else urljoin(phase['link'], match_info[match['id']].link)
grid[-1].append(match['id'])
leaderboard_teams = {}