summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--playoff.py12
-rw-r--r--playoff/sql.py4
-rw-r--r--playoff/template.py10
3 files changed, 21 insertions, 5 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 = {}
diff --git a/playoff/sql.py b/playoff/sql.py
index 0bd2df7..d5c28cd 100644
--- a/playoff/sql.py
+++ b/playoff/sql.py
@@ -21,3 +21,7 @@ JOIN #db#.scores sc2
JOIN #db#.admin
WHERE sc1.tabl = %s AND sc1.rnd = %s
'''
+
+PREFIX = '''
+SELECT shortname FROM #db#.admin
+'''
diff --git a/playoff/template.py b/playoff/template.py
index 5fe855c..65a846b 100644
--- a/playoff/template.py
+++ b/playoff/template.py
@@ -12,8 +12,12 @@ MATCH_TABLE = '''
MATCH_TEAM_ROW = '''
<tr>
-<td class="bd1">&nbsp;<a onmouseover="Tip('%s')" onmouseout="UnTip()">%s</a>&nbsp;</td>
-<td class="bdc">&nbsp;%.1f&nbsp;</td>
+<td class="bd1">&nbsp;<a href="%s" onmouseover="Tip('%s')" onmouseout="UnTip()">%s</a>&nbsp;</td>
+<td class="bdc">
+<a href="%s" target="_top">
+&nbsp;%.1f&nbsp;
+</a>
+</td>
</tr>
'''
@@ -54,7 +58,7 @@ MATCH_BOX = '''
LEADERBOARD = '''
<table border="0" cellspacing="0">
<tr>
-<td class="bdnl12" colspan="2" align="center"><b>KLASYFIKACJA KOŃCOWA</b></td>
+<td class="bdnl12" colspan="2" align="center"><b>&nbsp;KLASYFIKACJA KOŃCOWA&nbsp;</b></td>
</tr>
<tr>
<td class="e" colspan="2">&nbsp;</td>