~ubuntu-branches/ubuntu/intrepid/moin/intrepid-updates

« back to all changes in this revision

Viewing changes to MoinMoin/script/account/disable.py

  • Committer: Bazaar Package Importer
  • Author(s): Sivan Greenberg
  • Date: 2006-07-09 19:28:02 UTC
  • Revision ID: james.westby@ubuntu.com-20060709192802-oaeuvt4v3e9300uj
Tags: 1.5.3-1ubuntu1
* Merge new debian version.
* Reapply Ubuntu changes:
    + debian/rules:
      - Comment out usage of control.ubuntu.in (doesn't fit!).
    + debian/control.in:
      - Dropped python2.3 binary package.
    + debian/control:
      - Dropped python2.3 binary, again.
      - Dropped python2.3-dev from Build-Depends-Indep.
    + debian/patches/001-attachment-xss-fix.patch:
      - Dropped this patch. It's now in upstream's distribution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - disable a user account
 
4
 
 
5
    @copyright: 2006 by MoinMoin:ThomasWaldmann
 
6
    @license: GNU GPL, see COPYING for details.
 
7
"""
 
8
 
 
9
from MoinMoin.script._util import MoinScript
 
10
 
 
11
class PluginScript(MoinScript):
 
12
    def __init__(self, argv, def_values):
 
13
        MoinScript.__init__(self, argv, def_values)
 
14
        self.parser.add_option(
 
15
            "--uid", metavar="UID", dest="uid",
 
16
            help="Disable the user with user id UID."
 
17
        )
 
18
        self.parser.add_option(
 
19
            "--name", metavar="NAME", dest="uname",
 
20
            help="Disable the user with user name NAME."
 
21
        )
 
22
 
 
23
    def mainloop(self):
 
24
        # we don't expect non-option arguments
 
25
        if len(self.args) != 0:
 
26
            self.parser.error("incorrect number of arguments")
 
27
 
 
28
        flags_given = self.options.uid or self.options.uname
 
29
        if not flags_given:
 
30
            self.parser.print_help()
 
31
            import sys
 
32
            sys.exit(1)
 
33
 
 
34
        self.init_request()
 
35
        request = self.request
 
36
 
 
37
        from MoinMoin import user, wikiutil
 
38
        if self.options.uid:
 
39
            u = user.User(request, self.options.uid)
 
40
        elif self.options.uname:
 
41
            u = user.User(request, None, self.options.uname)
 
42
        print " %-20s %-25s %-35s" % (u.id, u.name, u.email),
 
43
        if not u.disabled: # only disable once
 
44
            u.disabled = 1
 
45
            u.name = "%s-%s" % (u.name, u.id)
 
46
            if u.email:
 
47
                u.email = "%s-%s" % (u.email, u.id)
 
48
            u.subscribed_pages = "" # avoid using email
 
49
            u.save()
 
50
            print "- disabled."
 
51
        else:
 
52
            print "- is already disabled."
 
53