From ef06b88555ee46c9dd199f83dce731d8a7b039a6 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 22 Feb 2017 14:40:52 +0100 Subject: Fetching prefixes for match links --- playoff.py | 12 ++++++++++-- playoff/sql.py | 4 ++++ playoff/template.py | 10 +++++++--- 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('
')]), + 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 @@ -107,6 +110,11 @@ def get_match_info(match): info.loser_matches += match['teams'][i]['loser'] 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] @@ -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 = ''' - %s  - %.1f  + %s  + + + %.1f  + + ''' @@ -54,7 +58,7 @@ MATCH_BOX = ''' LEADERBOARD = ''' - + -- cgit v1.2.3
KLASYFIKACJA KOŃCOWA KLASYFIKACJA KOŃCOWA