view MoinMoin/macro/SystemAdmin.py @ 3123:5cb80bd604b4

refactored _() getText calls to match new api
author Radomir Dopieralski <moindev@sheep.art.pl>
date Wed, 27 Feb 2008 00:28:28 +0100
parents bb2e053067fb
children 09657fbd4aa2
line wrap: on
line source
# -*- 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 execute(macro, args):
    _ = 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.form.get('sysadm', [None])[0]

    # 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)