No more office/syscom entries. Check if group is valid
authorMichael Ellis <me@michaelellis.ca>
Sat, 19 Jun 2010 01:03:17 +0000 (21:03 -0400)
committerMichael Ellis <me@michaelellis.ca>
Sat, 19 Jun 2010 01:03:17 +0000 (21:03 -0400)
ceo/members.py
ceo/urwid/groups.py
ceo/urwid/main.py
debian/changelog

index 8698957..be212f6 100644 (file)
@@ -232,6 +232,15 @@ def get(userid):
 
     return ldapi.lookup(ld, 'uid', userid, cfg['ldap_users_base'])
 
+def get_group(group):
+    """
+    Look up group by groupname
+
+    Returns a dictionary of group attributes
+    """
+
+    return ldapi.lookup(ld, 'cn', group, cfg['ldap_groups_base'])
+
 def uid2dn(uid):
     return 'uid=%s,%s' % (ldapi.escape(uid), cfg['ldap_users_base'])
 
index 1b27d9b..7fa93fe 100644 (file)
@@ -37,11 +37,7 @@ class IntroPage(WizardPanel):
             urwid.Text( "Adding a member to a club will also grant them "
                         "access to the club's files and allow them to "
                         "become_club."
-                        "\n\n"
-                        "Do not manage office and syscom related groups using "
-                        "this interface. Instead use the \"Manage Office "
-                        "Staff\" and \"Manage Systems Committee\" entries "
-                        "from the main menu." )
+                        "\n\n")
         ]
     def focusable(self):
         return False
@@ -57,13 +53,27 @@ class InfoPage(WizardPanel):
         ]
     def check(self):
         group = self.group.get_edit_text()
-        # TODO - check that group is valid
-        group_name = group # TODO
+
+        # check if group is valid
+        if not group or not members.get_group(group):
+            set_status("Group not found")
+            self.focus_widget(self.group)
+            return True
+
         data = {
             "name" : group,
-            "group" : group_name,
+            "group" : group,
             "groups" : [],
         }
+
+        # Office Staff and Syscom get added to more groups
+        if group == "syscom":
+            data["name"] = "Systems Committee"
+            data["groups"] = [ "office", "staff", "adm", "src" ]
+        elif group == "office":
+            data["name"] = "Office Staff"
+            data["groups"] = [ "cdrom", "audio", "video", "www" ]
+
         group_members(data)
 
 class ChangeMember(WizardPanel):
index 3417667..1fb18c9 100644 (file)
@@ -30,18 +30,6 @@ def program_name():
 
     return "%s %s %s" % (cword, eword, oword)
 
-office_data = {
-    "name" : "Office Staff",
-    "group" : "office",
-    "groups" : [ "cdrom", "audio", "video", "www" ],
-}
-
-syscom_data = {
-    "name" : "Systems Committee",
-    "group" : "syscom",
-    "groups" : [ "office", "staff", "adm", "src" ],
-}
-
 def new_member(*args, **kwargs):
     push_wizard("New Member", [
         newmember.IntroPage,
@@ -159,8 +147,6 @@ def top_menu():
     syscom_only = [
         ("Manage Club or Group Members", manage_group, None),
         ("Manage Positions", manage_positions, None),
-        ("Manage Office Staff", groups.group_members, office_data),
-        ("Manage Systems Committee", groups.group_members, syscom_data),
     ]
     unrestricted = [
         ("Display Member", display_member, None),
index 4bf777a..df22085 100644 (file)
@@ -1,3 +1,10 @@
+ceo (0.5.7+nmu2) stable; urgency=low
+
+  * Removed the need for separate entries to manage office and syscom
+  * Added check to ensure group is valid 
+
+ -- Michael Ellis <m2ellis@caffeine.csclub.uwaterloo.ca>  Fri, 18 Jun 2010 20:59:40 -0400
+
 ceo (0.5.7+nmu1) stable; urgency=low
 
   * Non-maintainer upload.