annotate MoinMoin/macro/SystemAdmin.py @ 4424:5ad5753ae311

pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 16 Nov 2008 22:20:21 +0100
parents 09657fbd4aa2
children
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
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
7 @copyright: 2001-2003 Juergen Hermann <jh@web.de>
0
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.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
12 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
13
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14 Dependencies = ["time"]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15
3229
09657fbd4aa2 converted to arg parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3123
diff changeset
16 def macro_SystemAdmin(macro):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17 _ = 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
18 request = macro.request
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 468
diff changeset
19
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 # 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
21 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
22 return ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 _MENU = {
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 1918
diff changeset
25 'attachments': (_("File attachment browser"), do_admin_browser),
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 1918
diff changeset
26 'users': (_("User account browser"), do_user_browser),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27 }
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3229
diff changeset
28 choice = request.values.get('sysadm')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30 # create menu
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
31 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
32 menuitems.sort()
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
33 result = []
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
34 f = macro.formatter
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
35 for label, fnid in menuitems:
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
36 if fnid == choice:
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
37 result.append(f.strong(1))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
38 result.append(f.text(label))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
39 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
40 else:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
41 #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
42 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
43 result.append(f.linebreak())
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
44 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
45
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 # add chosen content
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
47 if choice in _MENU:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
48 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
49
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
50 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
51