Silence pychecker and pylint warnings
[public/pyceo-broken.git] / pylib / csc / apps / urwid / main.py
index ee9bf7c..43f7ca7 100644 (file)
@@ -1,5 +1,5 @@
-import random, time, re
-import urwid, urwid.curses_display
+import random
+import urwid.curses_display
 
 from csc.apps.urwid.widgets import *
 from csc.apps.urwid.window import *
@@ -7,6 +7,8 @@ import csc.apps.urwid.newmember as newmember
 import csc.apps.urwid.renew as renew
 import csc.apps.urwid.info as info
 import csc.apps.urwid.search as search
+import csc.apps.urwid.positions as positions
+import csc.apps.urwid.groups as groups
 
 from csc.adm import accounts, members, terms
 from csc.common.excep import InvalidArgument
@@ -31,10 +33,10 @@ def program_name():
         "Embryonic", "Emigrant", "Emissary's", "Emoting", "Employment", "Emulated",
         "Enabling", "Enamoring", "Encapsulated", "Enchanted", "Encoded", "Encrypted",
         "Encumbered", "Endemic", "Enhanced", "Enigmatic", "Enlightened", "Enormous",
-        "Enrollment", "Enshrouded", "Ephermal", "Epidemic", "Episodic", "Epsilon",
+        "Enrollment", "Enshrouded", "Ephemeral", "Epidemic", "Episodic", "Epsilon",
         "Equitable", "Equestrian", "Equilateral", "Erroneous", "Erratic",
         "Espresso", "Essential", "Estate", "Esteemed", "Eternal", "Ethical", "Eucalyptus",
-        "Euphemistic", "Envangelist", "Evasive", "Everyday", "Evidence", "Eviction", "Evildoer's",
+        "Euphemistic", "Evangelist", "Evasive", "Everyday", "Evidence", "Eviction", "Evildoer's",
         "Evolution", "Exacerbation", "Exalted", "Examiner's", "Excise", "Exciting", "Exclusion",
         "Exec", "Executioner's", "Exile", "Existential", "Expedient", "Expert", "Expletive",
         "Exploiter's", "Explosive", "Exponential", "Exposing", "Extortion", "Extraction",
@@ -49,12 +51,14 @@ def program_name():
 
 office_data = {
     "name" : "Office Staff",
-    "group" : "office"
+    "group" : "office",
+    "groups" : [ "office", "cdrom", "audio", "video", "www" ],
 }
 
 syscom_data = {
     "name" : "Systems Committee",
-    "group" : "syscom"
+    "group" : "syscom",
+    "groups" : [ "office", "staff", "adm", "src" ],
 }
 
 def menu_items(items):
@@ -67,25 +71,18 @@ def main_menu():
         ("Create Club Account", new_club, None),
         ("Display Member", display_member, None),
         ("Search", search_members, None),
-        ("Manage Office Staff", group_members, office_data),
-        ("Manage Systems Committee", group_members, syscom_data),
+        ("Manage Club or Group Members", manage_group, None),
+        ("Manage Positions", manage_positions, None),
+        ("Manage Office Staff", groups.group_members,
+            (office_data, ui.uid)),
+        ("Manage Systems Committee", groups.group_members,
+            (syscom_data, ui.uid)),
         ("Exit", raise_abort, None),
     ]
 
     listbox = urwid.ListBox( menu_items( menu ) )
     return listbox
 
-def push_wizard(name, pages, dimensions=(50, 10)):
-    state = {}
-    wiz = Wizard()
-    for page in pages:
-        if type(page) != tuple:
-            page = (page, )
-        wiz.add_panel( page[0](state, *page[1:]) )
-    push_window( urwid.Filler( urwid.Padding(
-        urwid.LineBox(wiz), 'center', dimensions[0]),
-        'middle', dimensions[1] ), name )
-
 def new_member(*args, **kwargs):
     push_wizard("New Member", [
         newmember.IntroPage,
@@ -100,7 +97,13 @@ def new_club(*args, **kwargs):
         newmember.ClubIntroPage,
         newmember.ClubInfoPage,
         (newmember.EndPage, "club"),
-    ], (60,15))
+    ], (60, 15))
+
+def manage_group(*args, **kwargs):
+    push_wizard("Manage Club or Group Members", [
+        groups.IntroPage,
+        (groups.InfoPage, ui.uid),
+    ], (60, 15))
 
 def renew_member(*args, **kwargs):
     push_wizard("Renew Membership", [
@@ -137,34 +140,25 @@ def search_term(data):
 def search_group(data):
     push_wizard("By Group", [ search.GroupPage ])
 
-def group_members(data):
-    menu = [
-        ("Add %s member" % data["name"].lower(), add_group_member, data),
-        ("Remove %s member" % data["name"].lower(), remove_group_member, data),
-        ("List %s members" % data["name"].lower(), list_group_members, data),
-        ("Back", raise_back, None),
-    ]
-
-    listbox = urwid.ListBox( menu_items( menu ) )
-    push_window(listbox, "Manage %s" % data["name"])
-
-def add_group_member(data):
-    pass
-
-def remove_group_member(data):
-    pass
-
-def list_group_members(data):
-    if not members.connected(): members.connect()
-    mlist = members.list_group( data["group"] ).values()
-    search.member_list( mlist )
+def manage_positions(data):
+    push_wizard("Manage Positions", [
+        positions.IntroPage,
+        positions.InfoPage,
+        positions.EndPage,
+    ], (50, 15))
 
 def run():
+    members.connect()
+    accounts.connect()
+
     push_window( main_menu(), program_name() )
     event_loop( ui )
 
-def start():
+def start(uid, gid):
+    ui.uid = uid
+    ui.gid = gid
     ui.run_wrapper( run )
 
 if __name__ == '__main__':
-    start()
+    import os
+    start(os.getuid(), os.getgid())