[Mailman-Developers] Mass unsubscription

Dan Mick Dan Mick <Dan.Mick@West.Sun.COM>
Wed, 7 Jun 2000 20:45:16 -0700 (PDT)


Anyone have any comments?

Barry/Harald/whoever, as much discussion as this engendered on
mailman-users, if this looks good, maybe it could get squeezed into
beta3 (due any second now, right)?

------------- Begin Forwarded Message -------------

Date: Wed, 7 Jun 2000 20:21:30 -0700 (PDT)
From: Dan Mick <Dan.Mick@west.sun.com>
To: mailman-users@python.org
Subject: [Mailman-Users] Mass unsubscription
X-Beenthere: mailman-users@python.org
X-Mailman-Version: 2.0beta3
List-Id: Mailman mailing list management users <mailman-users.python.org>

In the "put up or shut up" category, I volunteer this patch to
add and process a "mass-unsubscribe" text box to the "Membership
Management" page for Mailman 1.1 (I haven't tried to make it 
apply to any 2.0 yet, although I'm sure the code will be similar).

It seems to work for me for a test list.  YMMV.  I'll submit
it over on mailman-developers too and see if anyone has any
criticism.

The file that changes is Cgi/admin.py:



*** admin.py.orig       Thu Jun  1 23:09:46 2000
--- admin.py    Wed Jun  7 20:18:52 2000
***************
*** 612,617 ****
--- 612,626 ----
      container.AddItem(Center(t))
      container.AddItem(Center(TextArea(name='subscribees',
                                        rows=10,cols=60,wrap=None)))
+     t = Table(width="90%")
+     t.AddRow([Center(Header(4, "Mass Remove Members"))])
+     t.AddCellInfo(t.GetCurrentRowIndex(),
+                   t.GetCurrentCellIndex(),
+                   bgcolor="#cccccc", colspan=8)
+     t.AddRow(["Enter one address to remove per line: <p>"])
+     container.AddItem(Center(t))
+     container.AddItem(Center(TextArea(name='unsubscribees',
+                                       rows=10,cols=60,wrap=None)))
      return container
  
  def FormatPasswordStuff():
***************
*** 877,882 ****
--- 886,920 ----
                      dirty = 1
          if unsubscribe_errors:
              document.AddItem(Header(5, "Error Unsubscribing:"))
+             items = map(lambda x: "%s -- %s" % (x[0], x[1]), 
unsubscribe_errors)
+             document.AddItem(apply(UnorderedList, tuple((items))))
+             document.AddItem("<p>")
+ 
+     #
+     # mass unsubscription processing for members category
+     #
+     if cgi_info.has_key('unsubscribees'):
+       name_text = cgi_info['unsubscribees'].value
+         name_text = string.replace(name_text, '\r', '')
+       names = map(string.strip, string.split(name_text, '\n'))
+         unsubscribe_errors = []
+         unsubscribe_success = []
+       for name in names:
+          try:
+             lst.DeleteMember(name)
+          except:
+             unsubscribe_errors.append(name, "No such user")
+          else:
+             unsubscribe_success.append(name)
+ 
+         if unsubscribe_success:
+             document.AddItem(Header(5, "Successfully Unsubscribed:"))
+             document.AddItem(apply(UnorderedList, 
tuple((unsubscribe_success))))
+             document.AddItem("<p>")
+             dirty = 1
+ 
+         if unsubscribe_errors:
+             document.AddItem(Header(5, "Error Unsubscribing:"))
              items = map(lambda x: "%s -- %s" % (x[0], x[1]), 
unsubscribe_errors)
              document.AddItem(apply(UnorderedList, tuple((items))))
              document.AddItem("<p>")


------------------------------------------------------
Mailman-Users maillist  -  Mailman-Users@python.org
http://www.python.org/mailman/listinfo/mailman-users

------------- End Forwarded Message -------------