File: SystemAdmin.py

package info (click to toggle)
moin 1.9.8-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 75,060 kB
  • ctags: 43,795
  • sloc: python: 118,348; java: 10,704; php: 2,374; perl: 1,572; xml: 371; makefile: 213; sh: 79; sed: 5
file content (51 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - System Administration

    Web interface to do MoinMoin system administration tasks.

    @copyright: 2001-2003 Juergen Hermann <jh@web.de>
    @license: GNU GPL, see COPYING for details.
"""

from MoinMoin.userform import do_user_browser
from MoinMoin.action.AttachFile import do_admin_browser

Dependencies = ["time"]

def macro_SystemAdmin(macro):
    _ = macro.request.getText
    request = macro.request

    # do not show system admin to users not in superuser list
    if not request.user.isSuperUser():
        return ''

    _MENU = {
        'attachments': (_("File attachment browser"), do_admin_browser),
        'users': (_("User account browser"), do_user_browser),
    }
    choice = request.values.get('sysadm')

    # create menu
    menuitems = [(label, fnid) for fnid, (label, handler) in _MENU.items()]
    menuitems.sort()
    result = []
    f = macro.formatter
    for label, fnid in menuitems:
        if fnid == choice:
            result.append(f.strong(1))
            result.append(f.text(label))
            result.append(f.strong(0))
        else:
            #result.append(wikiutil.link_tag(request, "%s?sysadm=%s" % (macro.formatter.page.page_name, id), label))
            result.append(f.page.link_to(request, label, querystr={'sysadm': fnid}))
        result.append(f.linebreak())
    result.append(f.linebreak())

    # add chosen content
    if choice in _MENU:
        result.append(f.rawHTML(_MENU[choice][1](request)))

    return ''.join(result)