Merge branch 'master' of /users/git/public/pyceo
[public/pyceo-broken.git] / ceo / urwid / main.py
index a5da33c..f28b17e 100644 (file)
@@ -1,9 +1,7 @@
-import random, ldap, urwid.curses_display
-from ceo import members, terms
-from ceo.excep import InvalidArgument
+import sys, random, urwid.curses_display
 from ceo.urwid.widgets import *
 from ceo.urwid.window import *
-from ceo.urwid import newmember, renew, info, search, positions, groups
+from ceo.urwid import newmember, renew, info, search, positions, groups, shell
 
 ui = urwid.curses_display.Screen()
 
@@ -44,7 +42,7 @@ def program_name():
 office_data = {
     "name" : "Office Staff",
     "group" : "office",
-    "groups" : [ "office", "cdrom", "audio", "video", "www" ],
+    "groups" : [ "cdrom", "floppy", "audio", "video", "www" ],
 }
 
 syscom_data = {
@@ -53,15 +51,15 @@ syscom_data = {
     "groups" : [ "office", "staff", "adm", "src" ],
 }
 
-def menu_items(items):
-    return [ urwid.AttrWrap( ButtonText( cb, data, txt ), 'menu', 'selected') for (txt, cb, data) in items ]
-
 def main_menu():
     menu = [
         ("New Member", new_member, None),
+        ("New Club Rep", new_club_user, None),
         ("Renew Membership", renew_member, None),
-        ("Create Club Account", new_club, None),
+        ("Renew Club Rep", renew_club_user, None),
+        ("New Club", new_club, None),
         ("Display Member", display_member, None),
+        ("Change Shell", change_shell, None),
         ("Search", search_members, None),
         ("Manage Club or Group Members", manage_group, None),
         ("Manage Positions", manage_positions, None),
@@ -89,6 +87,15 @@ def new_club(*args, **kwargs):
         (newmember.EndPage, "club"),
     ], (60, 15))
 
+def new_club_user(*args, **kwargs):
+    push_wizard("New Club Rep Account", [
+        newmember.ClubUserIntroPage,
+        newmember.InfoPage,
+        newmember.SignPage,
+        newmember.PassPage,
+        (newmember.EndPage, "clubuser"),
+    ], (60, 15))
+
 def manage_group(*args, **kwargs):
     push_wizard("Manage Club or Group Members", [
         groups.IntroPage,
@@ -104,6 +111,14 @@ def renew_member(*args, **kwargs):
         renew.EndPage,
     ])
 
+def renew_club_user(*args, **kwargs):
+    push_wizard("Renew Club Rep Account", [
+        renew.ClubUserIntroPage,
+        renew.UserPage,
+        (renew.TermPage, "clubuser"),
+        (renew.EndPage, "clubuser"),
+    ], (60, 15))
+
 def display_member(data):
     push_wizard("Display Member", [
         renew.UserPage,
@@ -137,19 +152,20 @@ def manage_positions(data):
         positions.EndPage,
     ], (50, 15))
 
-def run():
-    members.connect()
+def change_shell(data):
+    push_wizard("Change Shell", [
+        shell.IntroPage,
+        shell.YouPage,
+        shell.ShellPage,
+        shell.EndPage
+    ], (50, 20))
 
+def run():
     push_window( main_menu(), program_name() )
     event_loop( ui )
 
 def start():
-    try:
-        ui.run_wrapper( run )
-    except ldap.LOCAL_ERROR, e:
-        print e[0]['info']
-        print "Hint: You may need to run 'kinit'"
+    ui.run_wrapper( run )
 
 if __name__ == '__main__':
-    import os
     start()