2 from ceo import members, mysql
3 from ceo.urwid import search
4 from ceo.urwid.widgets import *
5 from ceo.urwid.window import *
7 class IntroPage(WizardPanel):
8 def init_widgets(self):
10 urwid.Text("MySQL databases"),
12 urwid.Text("Members and hosted clubs may have one MySQL database each. You may "
13 "create a database for an account if: \n"
15 "- It is your personal account,\n"
16 "- It is a club account, and you are in the club group, or\n"
17 "- You are on the CSC systems committee\n"
19 "You may also use this to reset your database password."
25 class UserPage(WizardPanel):
26 def init_widgets(self):
27 self.userid = LdapWordEdit(csclub_uri, csclub_base, 'uid',
31 urwid.Text("Member Information"),
33 urwid.Text("Enter the user which will own the new database."),
38 self.state['userid'] = self.userid.get_edit_text()
39 self.state['member'] = None
40 if self.state['userid']:
41 self.state['member'] = members.get(self.userid.get_edit_text())
42 if not self.state['member']:
43 set_status("Member not found")
44 self.focus_widget(self.userid)
47 class EndPage(WizardPanel):
48 def init_widgets(self):
49 self.headtext = urwid.Text("")
50 self.midtext = urwid.Text("")
62 password = mysql.create_mysql(self.state['userid'])
63 self.headtext.set_text("MySQL database created")
64 self.midtext.set_text("Connection Information: \n"
68 "Hostname: localhost\n"
71 "Note: Databases are only accessible from caffeine\n"
72 % (self.state['userid'], self.state['userid'], password))
73 except mysql.MySQLException, e:
74 self.headtext.set_text("Failed to create MySQL database")
75 self.midtext.set_text("We failed to create the database. The error was:\n\n%s" % e)