2009-08-22 16:09:12 -04:00
|
|
|
import ldap, urwid #, re
|
2010-09-25 01:00:27 -04:00
|
|
|
from ceo import members, terms, remote, uwldap
|
2007-12-13 03:39:05 -05:00
|
|
|
from ceo.urwid.widgets import *
|
|
|
|
from ceo.urwid.window import *
|
2007-09-23 22:32:56 -04:00
|
|
|
|
|
|
|
class IntroPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.widgets = [
|
|
|
|
urwid.Text( "Joining the Computer Science Club" ),
|
|
|
|
urwid.Divider(),
|
2010-09-24 21:11:36 -04:00
|
|
|
urwid.Text( "CSC membership is $2.00 per term. Please ensure "
|
2014-07-22 14:21:41 -04:00
|
|
|
"the fee is deposited into the cup before continuing." ),
|
2007-09-23 22:32:56 -04:00
|
|
|
]
|
|
|
|
def focusable(self):
|
|
|
|
return False
|
|
|
|
|
2007-10-05 02:22:01 -04:00
|
|
|
class ClubIntroPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.widgets = [
|
2007-12-20 16:43:33 -05:00
|
|
|
urwid.Text( "Club Accounts" ),
|
2007-10-05 02:22:01 -04:00
|
|
|
urwid.Divider(),
|
|
|
|
urwid.Text( "We provide other UW clubs accounts for email and "
|
|
|
|
"web hosting, free of charge. Like members, clubs "
|
|
|
|
"get web hosting at %s. We can also arrange for "
|
|
|
|
"uwaterloo.ca subdomains; please instruct the club "
|
|
|
|
"representative to contact the systems committee "
|
2007-12-20 16:43:33 -05:00
|
|
|
"for more information. Club accounts do not have "
|
|
|
|
"passwords, and exist primarily to own club data. "
|
|
|
|
% "http://csclub.uwaterloo.ca/~clubid/" ),
|
|
|
|
]
|
|
|
|
def focusable(self):
|
|
|
|
return False
|
|
|
|
|
2014-07-22 14:21:41 -04:00
|
|
|
class ClubNoPayPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.widgets = [
|
|
|
|
urwid.Text( "Club representative accounts are free. Please ensure "
|
|
|
|
"that no money was paid for this account." ),
|
|
|
|
]
|
|
|
|
def focusable(self):
|
|
|
|
return False
|
|
|
|
|
2007-12-20 16:43:33 -05:00
|
|
|
class ClubUserIntroPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.widgets = [
|
|
|
|
urwid.Text( "Club Rep Account" ),
|
|
|
|
urwid.Divider(),
|
|
|
|
urwid.Text( "This is for people who need access to a club account, "
|
|
|
|
"but are not currently interested in full CSC membership. "
|
|
|
|
"Registering a user in this way grants one term of free "
|
|
|
|
"access to our machines, without any other membership "
|
|
|
|
"privileges (they can't vote, hold office, etc). If such "
|
|
|
|
"a user later decides to join, use the Renew Membership "
|
|
|
|
"option." ),
|
2007-10-05 02:22:01 -04:00
|
|
|
]
|
|
|
|
def focusable(self):
|
|
|
|
return False
|
|
|
|
|
2007-09-23 22:32:56 -04:00
|
|
|
class InfoPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.name = SingleEdit("Full name: ")
|
|
|
|
self.program = SingleEdit("Program of Study: ")
|
2009-08-22 16:09:12 -04:00
|
|
|
self.email = SingleEdit("Email: ")
|
|
|
|
self.userid = LdapFilterWordEdit(uwldap.uri(), uwldap.base(), 'uid',
|
2009-08-06 02:32:51 -04:00
|
|
|
{'cn':self.name, 'ou':self.program}, "Username: ")
|
2007-09-23 22:32:56 -04:00
|
|
|
self.widgets = [
|
2009-08-06 02:32:51 -04:00
|
|
|
urwid.Text( "Member Information" ),
|
2007-09-23 22:32:56 -04:00
|
|
|
urwid.Divider(),
|
|
|
|
self.userid,
|
|
|
|
self.name,
|
|
|
|
self.program,
|
2009-08-22 16:09:12 -04:00
|
|
|
self.email,
|
2009-08-06 02:32:51 -04:00
|
|
|
urwid.Divider(),
|
|
|
|
urwid.Text("Notes:"),
|
|
|
|
urwid.Text("- Make sure to check ID (watcard, drivers license)"),
|
|
|
|
urwid.Text("- Make sure to use UW userids for current students\n (we check uwldap to see if you are a full member)"),
|
2007-09-23 22:32:56 -04:00
|
|
|
]
|
|
|
|
def check(self):
|
|
|
|
self.state['userid'] = self.userid.get_edit_text()
|
|
|
|
self.state['name'] = self.name.get_edit_text()
|
|
|
|
self.state['program'] = self.program.get_edit_text()
|
2009-08-22 16:09:12 -04:00
|
|
|
self.state['email'] = self.email.get_edit_text()
|
2021-05-02 18:12:44 -04:00
|
|
|
if len( self.state['userid'] ) < 2:
|
2007-09-23 22:32:56 -04:00
|
|
|
self.focus_widget( self.userid )
|
|
|
|
set_status("Username is too short")
|
|
|
|
return True
|
|
|
|
elif len( self.state['name'] ) < 4:
|
|
|
|
self.focus_widget( self.name )
|
|
|
|
set_status("Name is too short")
|
|
|
|
return True
|
2009-08-06 01:41:02 -04:00
|
|
|
elif self.state['userid'] == self.state['name']:
|
|
|
|
self.focus_widget(self.name)
|
|
|
|
set_status("Name matches username")
|
|
|
|
return True
|
2007-09-23 22:32:56 -04:00
|
|
|
clear_status()
|
|
|
|
|
2007-10-05 02:22:01 -04:00
|
|
|
class ClubInfoPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.userid = WordEdit("Username: ")
|
|
|
|
self.name = SingleEdit("Club Name: ")
|
|
|
|
self.widgets = [
|
|
|
|
urwid.Text( "Club Information" ),
|
|
|
|
urwid.Divider(),
|
|
|
|
self.userid,
|
|
|
|
self.name,
|
|
|
|
]
|
|
|
|
def check(self):
|
|
|
|
self.state['userid'] = self.userid.get_edit_text()
|
|
|
|
self.state['name'] = self.name.get_edit_text()
|
|
|
|
|
|
|
|
if len( self.state['userid'] ) < 3:
|
|
|
|
self.focus_widget( self.userid )
|
|
|
|
set_status("Username is too short")
|
|
|
|
return True
|
|
|
|
elif len( self.state['name'] ) < 4:
|
|
|
|
self.focus_widget( self.name )
|
|
|
|
set_status("Name is too short")
|
|
|
|
return True
|
2009-08-06 01:41:02 -04:00
|
|
|
elif self.state['userid'] == self.state['name']:
|
|
|
|
self.focus_widget(self.name)
|
|
|
|
set_status("Name matches username")
|
|
|
|
return True
|
2007-10-05 02:22:01 -04:00
|
|
|
clear_status()
|
|
|
|
|
2010-09-24 21:11:36 -04:00
|
|
|
class NumberOfTermsPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.count = SingleIntEdit("Count: ")
|
|
|
|
self.widgets = [
|
|
|
|
urwid.Text("Number of Terms"),
|
|
|
|
urwid.Divider(),
|
|
|
|
urwid.Text("The member will be initially registered for this many "
|
|
|
|
"consecutive terms.\n"),
|
|
|
|
self.count
|
|
|
|
]
|
|
|
|
|
|
|
|
def activate(self):
|
|
|
|
self.count.set_edit_text("1")
|
|
|
|
self.focus_widget(self.count)
|
|
|
|
|
|
|
|
def check(self):
|
|
|
|
self.state['terms'] = terms.interval(terms.current(), self.count.value())
|
|
|
|
|
|
|
|
if len(self.state['terms']) == 0:
|
|
|
|
self.focus_widget(self.count)
|
|
|
|
set_status("Registering for zero terms?")
|
|
|
|
return True
|
|
|
|
clear_status()
|
|
|
|
|
2007-09-23 22:32:56 -04:00
|
|
|
class SignPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.widgets = [
|
|
|
|
urwid.Text( "Machine Usage Policy" ),
|
|
|
|
urwid.Divider(),
|
|
|
|
urwid.Text( "Ensure the new member has signed the "
|
|
|
|
"Machine Usage Policy. Accounts of users who have not "
|
|
|
|
"signed will be suspended if discovered." ),
|
|
|
|
]
|
|
|
|
def focusable(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
class PassPage(WizardPanel):
|
|
|
|
def init_widgets(self):
|
|
|
|
self.password = PassEdit("Password: ")
|
|
|
|
self.pwcheck = PassEdit("Re-enter: ")
|
|
|
|
self.widgets = [
|
|
|
|
urwid.Text( "Member Password" ),
|
|
|
|
urwid.Divider(),
|
|
|
|
self.password,
|
|
|
|
self.pwcheck,
|
|
|
|
]
|
|
|
|
def focus_widget(self, widget):
|
|
|
|
self.box.set_focus( self.widgets.index( widget ) )
|
|
|
|
def clear_password(self):
|
|
|
|
self.focus_widget( self.password )
|
|
|
|
self.password.set_edit_text("")
|
|
|
|
self.pwcheck.set_edit_text("")
|
|
|
|
def check(self):
|
|
|
|
self.state['password'] = self.password.get_edit_text()
|
|
|
|
pwcheck = self.pwcheck.get_edit_text()
|
|
|
|
|
|
|
|
if self.state['password'] != pwcheck:
|
|
|
|
self.clear_password()
|
|
|
|
set_status("Passwords do not match")
|
|
|
|
return True
|
|
|
|
elif len(self.state['password']) < 5:
|
|
|
|
self.clear_password()
|
|
|
|
set_status("Password is too short")
|
|
|
|
return True
|
|
|
|
clear_status()
|
|
|
|
|
|
|
|
class EndPage(WizardPanel):
|
2007-10-05 02:22:01 -04:00
|
|
|
def __init__(self, state, utype='member'):
|
2007-12-12 01:15:12 -05:00
|
|
|
self.utype = utype
|
2007-10-05 02:22:01 -04:00
|
|
|
WizardPanel.__init__(self, state)
|
2007-09-23 22:32:56 -04:00
|
|
|
def init_widgets(self):
|
|
|
|
self.headtext = urwid.Text("")
|
|
|
|
self.midtext = urwid.Text("")
|
|
|
|
self.widgets = [
|
|
|
|
self.headtext,
|
|
|
|
urwid.Divider(),
|
|
|
|
self.midtext,
|
|
|
|
]
|
|
|
|
def focusable(self):
|
|
|
|
return False
|
|
|
|
def check(self):
|
|
|
|
pop_window()
|
|
|
|
def activate(self):
|
2009-09-16 18:03:04 -04:00
|
|
|
self.headtext.set_text("Adding %s" % self.state['userid'])
|
|
|
|
self.midtext.set_text("Please be patient while the user is added. "
|
|
|
|
"If more than a few seconds pass, check for a "
|
|
|
|
"phase variance and try inverting the polarity.")
|
2009-09-16 17:32:11 -04:00
|
|
|
set_status("Contacting the gibson...")
|
2009-09-16 18:03:04 -04:00
|
|
|
|
|
|
|
redraw()
|
|
|
|
|
2007-10-05 02:22:01 -04:00
|
|
|
problem = None
|
2007-12-10 02:33:51 -05:00
|
|
|
try:
|
2007-12-12 01:15:12 -05:00
|
|
|
if self.utype == 'member':
|
2011-08-26 03:03:32 -04:00
|
|
|
members.create_member(
|
|
|
|
self.state['userid'],
|
|
|
|
self.state['password'],
|
|
|
|
self.state['name'],
|
|
|
|
self.state['program'],
|
|
|
|
self.state['email'])
|
|
|
|
members.register(self.state['userid'], self.state['terms'])
|
2010-09-25 01:00:27 -04:00
|
|
|
|
2011-08-26 03:03:32 -04:00
|
|
|
mailman_result = members.subscribe_to_mailing_list(self.state['userid'])
|
2021-05-18 01:52:09 -04:00
|
|
|
if mailman_result != 'None':
|
2010-09-25 01:00:27 -04:00
|
|
|
problem = mailman_result
|
2011-08-26 03:03:32 -04:00
|
|
|
|
2007-12-20 16:43:33 -05:00
|
|
|
elif self.utype == 'clubuser':
|
2011-08-26 03:03:32 -04:00
|
|
|
members.create_member(
|
|
|
|
self.state['userid'],
|
|
|
|
self.state['password'],
|
|
|
|
self.state['name'],
|
|
|
|
self.state['program'],
|
|
|
|
self.state['email'],
|
|
|
|
club_rep=True)
|
|
|
|
members.register_nonmember(self.state['userid'], self.state['terms'])
|
2007-12-12 01:15:12 -05:00
|
|
|
elif self.utype == 'club':
|
2011-08-26 03:03:32 -04:00
|
|
|
members.create_club(self.state['userid'], self.state['name'])
|
2007-12-10 02:33:51 -05:00
|
|
|
else:
|
|
|
|
raise Exception("Internal Error")
|
2007-12-12 00:56:57 -05:00
|
|
|
except members.InvalidArgument, e:
|
2007-12-10 02:33:51 -05:00
|
|
|
problem = str(e)
|
2007-12-13 23:53:15 -05:00
|
|
|
except ldap.LDAPError, e:
|
2007-12-10 02:33:51 -05:00
|
|
|
problem = str(e)
|
2007-12-13 23:53:15 -05:00
|
|
|
except members.MemberException, e:
|
2007-12-10 02:33:51 -05:00
|
|
|
problem = str(e)
|
2010-09-25 01:00:27 -04:00
|
|
|
except remote.RemoteException, e:
|
|
|
|
problem = str(e)
|
2007-12-10 02:33:51 -05:00
|
|
|
|
2009-09-16 18:03:04 -04:00
|
|
|
clear_status()
|
|
|
|
|
2007-09-23 22:32:56 -04:00
|
|
|
if problem:
|
2007-12-10 02:33:51 -05:00
|
|
|
self.headtext.set_text("Failures Occured Adding User")
|
2007-12-13 23:53:15 -05:00
|
|
|
self.midtext.set_text("The error was:\n\n%s\n\nThe account may be partially added "
|
|
|
|
"and you may or may not be able to log in. Or perhaps you are not office staff. "
|
|
|
|
"If this was not expected please contact systems committee." % problem)
|
2007-12-10 02:33:51 -05:00
|
|
|
return
|
2007-09-23 22:32:56 -04:00
|
|
|
else:
|
2009-09-16 18:03:04 -04:00
|
|
|
set_status("Strombola Delivers")
|
2007-10-05 02:22:01 -04:00
|
|
|
self.headtext.set_text("User Added")
|
2007-09-23 22:32:56 -04:00
|
|
|
self.midtext.set_text("Congratulations, %s has been added "
|
2007-12-10 02:33:51 -05:00
|
|
|
"successfully. You should also rebuild the website in "
|
|
|
|
"order to update the memberlist."
|
|
|
|
% self.state['userid'])
|