Allow CM club to disable mailman subscription
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Sat, 17 Sep 2011 20:09:23 +0000 (16:09 -0400)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Sat, 17 Sep 2011 20:28:49 +0000 (16:28 -0400)
This features breaks CMC ceo.

ceo/urwid/newmember.py
debian/ceo-common.install
etc/mailman.cf [new file with mode: 0644]
src/op-mailman

index b62785b..04a969e 100644 (file)
@@ -216,7 +216,7 @@ class EndPage(WizardPanel):
                 members.register(self.state['userid'], self.state['terms'])
 
                 mailman_result = members.subscribe_to_mailing_list(self.state['userid'])
-                if mailman_result.split(': ',1)[0] not in ('Subscribed', 'Already a member'):
+                if mailman_result.split(': ',1)[0] not in ('Subscribed', 'Already a member', 'Disabled'):
                     problem = mailman_result
 
             elif self.utype == 'clubuser':
index 5561095..26340e9 100644 (file)
@@ -1 +1 @@
-etc/accounts.cf etc/library.cf etc/ops etc/spam etc/csc
+etc/*.cf etc/ops etc/spam etc/csc
diff --git a/etc/mailman.cf b/etc/mailman.cf
new file mode 100644 (file)
index 0000000..e5a5472
--- /dev/null
@@ -0,0 +1,2 @@
+members_list = csc-general
+list_domain = csclub.uwaterloo.ca
index d995a08..8ad3ca8 100755 (executable)
@@ -2,20 +2,43 @@
 
 import os, syslog
 from subprocess import Popen, PIPE, STDOUT
+from ceo import conf
 from ceo.ops import get_ceo_user, check_group
 
+CONFIG_FILE = '/etc/csc/mailman.cf'
+
+cfg = {}
+
+def configure():
+    string_fields = ['members_list', 'list_domain']
+
+    # read configuration file
+    cfg_tmp = conf.read(CONFIG_FILE)
+
+    # verify configuration
+    conf.check_string_fields(CONFIG_FILE, string_fields, cfg_tmp)
+
+    # update the current configuration with the loaded values
+    cfg.update(cfg_tmp)
+
 def main():
+    configure()
+
     remote_user = get_ceo_user()
     user_to_add = raw_input()
-    
+
+    if cfg['members_list'] == 'none':
+        print 'Disabled: %s' % user_to_add
+        return
+
     if remote_user == user_to_add or check_group(remote_user, 'office') or check_group(remote_user, 'syscom'):
-        mailman = Popen(["/var/lib/mailman/bin/add_members", "-r", "-", "csc-general"],
+        mailman = Popen(["/var/lib/mailman/bin/add_members", "-r", "-", cfg['members_list']],
                         stdin=PIPE, stdout=PIPE, stderr=STDOUT)
-        out, err = mailman.communicate("%s@csclub.uwaterloo.ca\n" % user_to_add)
+        out, err = mailman.communicate("%s@%s\n" % (user_to_add, cfg['list_domain']))
         syslog.syslog(syslog.LOG_INFO, out)
         print out
     else:
-        message = "Access denied: user '%s' cannot subscribe users to csc-general" % remote_user
+        message = "Access denied: user '%s' cannot subscribe users to %s" % (remote_user, cfg['members_list'])
         syslog.syslog(syslog.LOG_NOTICE, message)
         print message