]> git.zarvox.org Git - wp3.git/blob - pagenetid.py
Added Python docstrings for all classes.
[wp3.git] / pagenetid.py
1 from PyQt4.QtCore import *
2 from PyQt4.QtGui import *
3 from PyQt4.QtSql import *
4
5 class PageNetID(QWizardPage):
6         def __init__(self, parent=None, db=None ):
7                 """Display disclaimer and get NetID from user."""
8                 QWizardPage.__init__(self,parent)
9                 self.db = db
10                 self.instructions = QLabel("&Enter your NetID:")
11                 self.netid = QLineEdit()
12                 self.instructions.setBuddy(self.netid)
13                 self.disclaimer = QLabel("This information is being collected to be distributed to residents of the Clements, Lechner, and McFadden dorms for the 2009-2010 school year.  By entering your NetID and other information into this database, you give permission for this information to be distributed to other residents who have also shared their personal information.\n\nThe information collected will be used to make the White Pages, a listing of contact information for residents of Clements, Lechner, and McFadden Halls, to be published later this year.")
14                 self.disclaimer.setWordWrap(True)
15                 self.dupelabel = QLabel()
16                 self.registerField("netid*", self.netid)
17                 self.grid = QGridLayout()
18                 self.grid.addWidget(self.instructions,0,0)
19                 self.grid.addWidget(self.netid,0,1)
20                 self.grid.addWidget(self.disclaimer,1,0,1,2)
21                 self.grid.addWidget(self.dupelabel,2,0,1,2)
22                 self.setLayout(self.grid)
23                 self.setTitle("Move-in Wizard")
24                 self.setSubTitle("Enter your NetID:")
25         def validatePage(self):
26                 """Make sure the NetID doesn't already exist in this database - if it does, we already have this person's data."""
27                 netid = self.field("netid")
28                 q = QSqlQuery()
29                 q.prepare("SELECT * FROM people where netid = :netid")
30                 q.bindValue(":netid", netid)
31                 q.exec_()
32                 if q.next():
33                         print netid.toString(), "is already in the database"
34                         self.dupelabel.setText( netid.toString() + QString(" is already in the database."))
35                         return False
36                 return True
37
38
39 if __name__ == "__main__":
40         a = QApplication([""])
41         wiz = QWizard()
42         p = PageNetID()
43         wiz.addPage(p)
44         wiz.resize(400,300)
45         wiz.show()
46         a.exec_()
47