]> git.zarvox.org Git - wp3.git/blobdiff - pagenetid.py
Added Python docstrings for all classes.
[wp3.git] / pagenetid.py
index 38f593ccbc3f6b38b689abad6d3c4f769f56da7f..6ce0b9f74823547a4de1fded0f32adb4c7896fb7 100644 (file)
@@ -1,19 +1,40 @@
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
+from PyQt4.QtSql import *
 
 class PageNetID(QWizardPage):
-       def __init__(self, parent=None):
+       def __init__(self, parent=None, db=None ):
+               """Display disclaimer and get NetID from user."""
                QWizardPage.__init__(self,parent)
+               self.db = db
                self.instructions = QLabel("&Enter your NetID:")
                self.netid = QLineEdit()
                self.instructions.setBuddy(self.netid)
+               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.")
+               self.disclaimer.setWordWrap(True)
+               self.dupelabel = QLabel()
                self.registerField("netid*", self.netid)
                self.grid = QGridLayout()
                self.grid.addWidget(self.instructions,0,0)
                self.grid.addWidget(self.netid,0,1)
+               self.grid.addWidget(self.disclaimer,1,0,1,2)
+               self.grid.addWidget(self.dupelabel,2,0,1,2)
                self.setLayout(self.grid)
                self.setTitle("Move-in Wizard")
                self.setSubTitle("Enter your NetID:")
+       def validatePage(self):
+               """Make sure the NetID doesn't already exist in this database - if it does, we already have this person's data."""
+               netid = self.field("netid")
+               q = QSqlQuery()
+               q.prepare("SELECT * FROM people where netid = :netid")
+               q.bindValue(":netid", netid)
+               q.exec_()
+               if q.next():
+                       print netid.toString(), "is already in the database"
+                       self.dupelabel.setText( netid.toString() + QString(" is already in the database."))
+                       return False
+               return True
+
 
 if __name__ == "__main__":
        a = QApplication([""])