From 6193168b2ddeb579742f0df171979ca0ce2e7b93 Mon Sep 17 00:00:00 2001 From: Jeremy Roman Date: Fri, 24 Sep 2010 21:11:36 -0400 Subject: [PATCH] add new members for multiple terms --- ceo/urwid/main.py | 2 ++ ceo/urwid/newmember.py | 30 +++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ceo/urwid/main.py b/ceo/urwid/main.py index 1fb18c9..b9694cc 100644 --- a/ceo/urwid/main.py +++ b/ceo/urwid/main.py @@ -34,6 +34,7 @@ def new_member(*args, **kwargs): push_wizard("New Member", [ newmember.IntroPage, newmember.InfoPage, + newmember.NumberOfTermsPage, newmember.SignPage, newmember.PassPage, newmember.EndPage, @@ -50,6 +51,7 @@ def new_club_user(*args, **kwargs): push_wizard("New Club Rep Account", [ newmember.ClubUserIntroPage, newmember.InfoPage, + newmember.NumberOfTermsPage, newmember.SignPage, newmember.PassPage, (newmember.EndPage, "clubuser"), diff --git a/ceo/urwid/newmember.py b/ceo/urwid/newmember.py index fd76cf1..5007bfe 100644 --- a/ceo/urwid/newmember.py +++ b/ceo/urwid/newmember.py @@ -8,7 +8,7 @@ class IntroPage(WizardPanel): self.widgets = [ urwid.Text( "Joining the Computer Science Club" ), urwid.Divider(), - urwid.Text( "CSC membership is $2.00 for one term. Please ensure " + urwid.Text( "CSC membership is $2.00 per term. Please ensure " "the fee is deposited into the safe before continuing." ), ] def focusable(self): @@ -113,6 +113,30 @@ class ClubInfoPage(WizardPanel): return True clear_status() +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() + class SignPage(WizardPanel): def init_widgets(self): self.widgets = [ @@ -184,10 +208,10 @@ class EndPage(WizardPanel): try: if self.utype == 'member': members.create_member( self.state['userid'], self.state['password'], self.state['name'], self.state['program'], self.state['email'] ) - members.register( self.state['userid'], terms.current() ) + members.register( self.state['userid'], self.state['terms'] ) elif self.utype == 'clubuser': members.create_member( self.state['userid'], self.state['password'], self.state['name'], self.state['program'], self.state['email'] ) - members.register_nonmember( self.state['userid'], terms.current() ) + members.register_nonmember( self.state['userid'], self.state['terms'] ) elif self.utype == 'club': members.create_club( self.state['userid'], self.state['name'] ) else: