]> git.zarvox.org Git - wp3.git/blob - pagecommit.py
Added Python docstrings for all classes.
[wp3.git] / pagecommit.py
1 from PyQt4.QtCore import *
2 from PyQt4.QtGui import *
3 from PyQt4.QtSql import *
4
5 class PageCommit(QWizardPage):
6         def __init__(self, parent=None, db=None):
7                 """Set up widgets and message to have picture taken."""
8                 QWizardPage.__init__(self,parent)
9                 self.db = db
10                 self.instructions = QLabel("You're done with the computer.  Go have your picture taken.\n\nThe SAs/PAs will add the photo to your data.")
11                 self.instructions.setWordWrap(True)
12                 self.grid = QGridLayout()
13                 self.grid.addWidget(self.instructions,0,0)
14                 self.setLayout(self.grid)
15                 self.setTitle("Move-in Wizard")
16                 self.setSubTitle("Photo")
17
18         def initializePage(self):
19                 """Add data collected from previous pages to database."""
20                 q = QSqlQuery(self.db)
21                 q.prepare("INSERT INTO people (netid, forename, surname, email, birthday, phone, major, dorm, room, createtime, mtime )"
22                                 "VALUES (:netid, :forename, :surname, :email, :birthday, :phone, :major, :dorm, :room, :createtime, :mtime )" );
23                 q.bindValue(":netid", self.field("netid") )
24                 q.bindValue(":forename", self.field("forename") )
25                 q.bindValue(":surname", self.field("surname") )
26                 q.bindValue(":email", self.field("email") )
27                 y = self.field("year").toInt()[0] + 1983
28                 m = self.field("month").toInt()[0] + 1
29                 d = self.field("day").toInt()[0] + 1
30                 bday = QDate(y,m,d)
31                 q.bindValue(":birthday", QVariant(bday.toString(Qt.ISODate)) )
32                 q.bindValue(":phone", self.field("phone") )
33                 q.bindValue(":major", self.field("major") )
34                 q.bindValue(":dorm", QVariant(QString(["","Clements","Lechner","McFadden"][self.field("dorm").toInt()[0]])) )
35                 q.bindValue(":room", self.field("room") )
36                 q.bindValue(":createtime", QVariant(QDateTime.currentDateTime().toString(Qt.ISODate)) )
37                 q.bindValue(":mtime", QVariant(QDateTime.currentDateTime().toString(Qt.ISODate)) )
38                 q.exec_()
39                 print "Inserted into database"
40
41 if __name__ == "__main__":
42         a = QApplication([""])
43         wiz = QWizard()
44         p = PageCommit()
45         wiz.addPage(p)
46         wiz.resize(400,300)
47         wiz.show()
48         a.exec_()
49