add button to display info from TP to tourneyviewer

This commit is contained in:
steffen123 2010-08-09 23:41:48 +02:00
parent c5bd036b6e
commit bb743b4567
3 changed files with 66 additions and 8 deletions

View File

@ -2120,7 +2120,6 @@ class Database:
c = self.get_cursor() c = self.get_cursor()
c.execute(self.sql.query['getTourneyInfo'], (siteName, tourneyNo)) c.execute(self.sql.query['getTourneyInfo'], (siteName, tourneyNo))
columnNames=c.description columnNames=c.description
#print "columnNames:",columnNames
names=[] names=[]
for column in columnNames: for column in columnNames:
@ -2129,6 +2128,19 @@ class Database:
data=c.fetchone() data=c.fetchone()
return (names,data) return (names,data)
#end def getTourneyInfo #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 #end class Database
# Class used to hold all the data needed to write a hand to the db # Class used to hold all the data needed to write a hand to the db

View File

@ -37,21 +37,28 @@ class GuiTourneyViewer (threading.Thread):
label=gtk.Label("Enter the tourney number you want to display:") label=gtk.Label("Enter the tourney number you want to display:")
self.interfaceHBox.add(label) self.interfaceHBox.add(label)
self.entryBox = gtk.Entry() self.entryTourney = gtk.Entry()
self.interfaceHBox.add(self.entryBox) self.interfaceHBox.add(self.entryTourney)
self.button = gtk.Button("_Display") self.displayButton = gtk.Button("_Display")
self.button.connect('clicked', self.displayClicked) self.displayButton.connect('clicked', self.displayClicked)
self.interfaceHBox.add(self.button) 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.table = gtk.Table(columns=10, rows=9)
self.mainVBox.add(self.table) self.mainVBox.add(self.table)
self.mainVBox.show_all() self.mainVBox.show_all()
#end def __init__ #end def __init__
def displayClicked(self, widget, data=None): def displayClicked(self, widget, data=None):
tourneyNo=int(self.entryBox.get_text()) tourneyNo=int(self.entryTourney.get_text())
siteName=self.siteBox.get_active_text() siteName=self.siteBox.get_active_text()
self.table.destroy() self.table.destroy()
@ -79,6 +86,36 @@ class GuiTourneyViewer (threading.Thread):
self.mainVBox.show_all() self.mainVBox.show_all()
#def displayClicked #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): def get_vbox(self):
"""returns the vbox of this thread""" """returns the vbox of this thread"""
return self.mainVBox return self.mainVBox

View File

@ -3819,6 +3819,15 @@ class Sql:
WHERE s.name=%s AND t.siteTourneyNo=%s 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 self.query['insertTourney'] = """INSERT INTO Tourneys
(tourneyTypeId, siteTourneyNo, entries, prizepool, (tourneyTypeId, siteTourneyNo, entries, prizepool,
startTime, endTime, tourneyName, matrixIdProcessed, startTime, endTime, tourneyName, matrixIdProcessed,