annotate MoinMoin/macro/SystemAdmin.py @ 1384:d1ceb31f3d02

make more use of formatter
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 21 Aug 2006 09:59:57 +0200
parents 4eb66637ccd0
children 6dd2e29acffe
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - System Administration
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
5 Web interface to do MoinMoin system administration tasks.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 @copyright: 2001, 2003 by Jürgen Hermann <jh@web.de>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11 from MoinMoin import wikiutil
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 from MoinMoin.util import pysupport
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 from MoinMoin.userform import do_user_browser
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14 from MoinMoin.action.AttachFile import do_admin_browser
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 Dependencies = ["time"]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 def execute(macro, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 _ = macro.request.getText
363
89d0a178964a 1.5.0 release final changes: updated docs, i18n, underlay, interwiki. fixed SystemAdmin macro to use cfg.superuser.
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
20 request = macro.request
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 468
diff changeset
21
363
89d0a178964a 1.5.0 release final changes: updated docs, i18n, underlay, interwiki. fixed SystemAdmin macro to use cfg.superuser.
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
22 # do not show system admin to users not in superuser list
448
45924beef130 user.isSuperUser() check, require cfg.superuser being a list or tuple
Thomas Waldmann <tw@waldmann-edv.de>
parents: 363
diff changeset
23 if not request.user.isSuperUser():
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 return ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 _MENU = {
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27 'attachments': (("File attachment browser"), do_admin_browser),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28 'users': (("User account browser"), do_user_browser),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 }
363
89d0a178964a 1.5.0 release final changes: updated docs, i18n, underlay, interwiki. fixed SystemAdmin macro to use cfg.superuser.
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
30 choice = request.form.get('sysadm', [None])[0]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 # create menu
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
33 menuitems = [(label, fnid) for fnid, (label, handler) in _MENU.items()]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
34 menuitems.sort()
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
35 result = []
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
36 f = macro.formatter
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
37 for label, fnid in menuitems:
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
38 if fnid == choice:
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
39 result.append(f.strong(1))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
40 result.append(f.text(label))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
41 result.append(f.strong(0))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 else:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
43 #result.append(wikiutil.link_tag(request, "%s?sysadm=%s" % (macro.formatter.page.page_name, id), label))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
44 result.append(f.page.link_to(request, label, querystr={'sysadm': fnid}))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
45 result.append(f.linebreak())
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
46 result.append(f.linebreak())
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 # add chosen content
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 if _MENU.has_key(choice):
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
50 result.append(f.rawHTML(_MENU[choice][1](request)))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
52 return ''.join(result)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53