From bb743b45677e74c60a70f7a49c86766278ba69e8 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Mon, 9 Aug 2010 23:41:48 +0200 Subject: [PATCH] add button to display info from TP to tourneyviewer --- pyfpdb/Database.py | 14 ++++++++++- pyfpdb/GuiTourneyViewer.py | 51 ++++++++++++++++++++++++++++++++------ pyfpdb/SQL.py | 9 +++++++ 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 90a464ba..6b902921 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -2120,7 +2120,6 @@ class Database: c = self.get_cursor() c.execute(self.sql.query['getTourneyInfo'], (siteName, tourneyNo)) columnNames=c.description - #print "columnNames:",columnNames names=[] for column in columnNames: @@ -2129,6 +2128,19 @@ class Database: data=c.fetchone() return (names,data) #end def getTourneyInfo + + def getTourneyPlayerInfo(self, siteName, tourneyNo, playerName): + c = self.get_cursor() + c.execute(self.sql.query['getTourneyPlayerInfo'], (siteName, tourneyNo, playerName)) + columnNames=c.description + + names=[] + for column in columnNames: + names.append(column[0]) + + data=c.fetchone() + return (names,data) + #end def getTourneyPlayerInfo #end class Database # Class used to hold all the data needed to write a hand to the db diff --git a/pyfpdb/GuiTourneyViewer.py b/pyfpdb/GuiTourneyViewer.py index ab0bb38d..1499e8a6 100644 --- a/pyfpdb/GuiTourneyViewer.py +++ b/pyfpdb/GuiTourneyViewer.py @@ -37,21 +37,28 @@ class GuiTourneyViewer (threading.Thread): label=gtk.Label("Enter the tourney number you want to display:") self.interfaceHBox.add(label) - self.entryBox = gtk.Entry() - self.interfaceHBox.add(self.entryBox) + self.entryTourney = gtk.Entry() + self.interfaceHBox.add(self.entryTourney) - self.button = gtk.Button("_Display") - self.button.connect('clicked', self.displayClicked) - self.interfaceHBox.add(self.button) + self.displayButton = gtk.Button("_Display") + self.displayButton.connect('clicked', self.displayClicked) + self.interfaceHBox.add(self.displayButton) + + self.entryPlayer = gtk.Entry() + self.interfaceHBox.add(self.entryPlayer) + + self.playerButton = gtk.Button("Display _Player") + self.playerButton.connect('clicked', self.displayPlayerClicked) + self.interfaceHBox.add(self.playerButton) self.table = gtk.Table(columns=10, rows=9) self.mainVBox.add(self.table) - + self.mainVBox.show_all() #end def __init__ def displayClicked(self, widget, data=None): - tourneyNo=int(self.entryBox.get_text()) + tourneyNo=int(self.entryTourney.get_text()) siteName=self.siteBox.get_active_text() self.table.destroy() @@ -79,6 +86,36 @@ class GuiTourneyViewer (threading.Thread): self.mainVBox.show_all() #def displayClicked + def displayPlayerClicked(self, widget, data=None): + tourneyNo=int(self.entryTourney.get_text()) + siteName=self.siteBox.get_active_text() + playerName=self.entryPlayer.get_text() + + self.table.destroy() + self.table=gtk.Table(columns=4, rows=5) + self.mainVBox.add(self.table) + + result=self.db.getTourneyPlayerInfo(siteName, tourneyNo, playerName) + x=0 + y=0 + for i in range(1,len(result[0])): + if y==5: + x+=2 + y=0 + + label=gtk.Label(result[0][i]) + self.table.attach(label,x,x+1,y,y+1) + + if result[1][i]==None: + label=gtk.Label("N/A") + else: + label=gtk.Label(result[1][i]) + self.table.attach(label,x+1,x+2,y,y+1) + + y+=1 + self.mainVBox.show_all() + #def displayPlayerClicked + def get_vbox(self): """returns the vbox of this thread""" return self.mainVBox diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 216d91cc..69d74fbe 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -3819,6 +3819,15 @@ class Sql: WHERE s.name=%s AND t.siteTourneyNo=%s """ + self.query['getTourneyPlayerInfo'] = """SELECT tp.* + FROM Tourneys t + INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id) + INNER JOIN Sites s ON (tt.siteId = s.id) + INNER JOIN TourneysPlayers tp ON (tp.tourneyId = t.id) + INNER JOIN Players p ON (p.id = tp.playerId) + WHERE s.name=%s AND t.siteTourneyNo=%s AND p.name=%s + """ + self.query['insertTourney'] = """INSERT INTO Tourneys (tourneyTypeId, siteTourneyNo, entries, prizepool, startTime, endTime, tourneyName, matrixIdProcessed,