Back to index

moin  1.9.0~rc2
Functions
MoinMoin.userform.admin Namespace Reference

Functions

def do_user_browser

Function Documentation

Browser for SystemAdmin macro. 

Definition at line 20 of file admin.py.

00020 
00021 def do_user_browser(request):
00022     """ Browser for SystemAdmin macro. """
00023     _ = request.getText
00024     groups = request.groups
00025 
00026     data = TupleDataset()
00027     data.columns = [
00028         Column('name', label=_('Username')),
00029         Column('groups', label=_('Member of Groups')),
00030         Column('email', label=_('Email')),
00031         Column('jabber', label=_('Jabber')),
00032         Column('action', label=_('Action')),
00033     ]
00034 
00035     # Iterate over users
00036     for uid in user.getUserList(request):
00037         account = user.User(request, uid)
00038 
00039         account_groups = set(groups.groups_with_member(account.name))
00040         wiki_groups = set([group for group in account_groups if isinstance(groups[group], WikiGroup)])
00041         other_groups = list(account_groups - wiki_groups)
00042 
00043         # First show groups that are defined in wikipages linking to it
00044         # after show groups from other backends.
00045         grouppage_links = ', '.join([Page(request, group_name).link_to(request) for group_name in wiki_groups] +
00046                                     other_groups)
00047 
00048         userhomepage = Page(request, account.name)
00049         if userhomepage.exists():
00050             namelink = userhomepage.link_to(request)
00051         else:
00052             namelink = wikiutil.escape(account.name)
00053 
00054         # creates the POST data for account disable/enable
00055         val = "1"
00056         text=_('Disable user')
00057         if account.disabled:
00058             text=_('Enable user')
00059             val = "0"
00060             namelink += " (%s)" % _("disabled")
00061 
00062         url = request.page.url(request)
00063         ret = html.FORM(action=url)
00064         ret.append(html.INPUT(type='hidden', name='action', value='userprofile'))
00065         ret.append(html.INPUT(type='hidden', name='name', value=account.name))
00066         ret.append(html.INPUT(type='hidden', name='key', value="disabled"))
00067         ret.append(html.INPUT(type='hidden', name='val', value=val))
00068         ret.append(html.INPUT(type='submit', name='userprofile', value=text))
00069         enable_disable_link = unicode(unicode(ret))
00070 
00071         # creates the POST data for recoverpass
00072         url = request.page.url(request)
00073         ret = html.FORM(action=url)
00074         ret.append(html.INPUT(type='hidden', name='action', value='recoverpass'))
00075         ret.append(html.INPUT(type='hidden', name='email', value=account.email))
00076         ret.append(html.INPUT(type='hidden', name='account_sendmail', value="1"))
00077         ret.append(html.INPUT(type='hidden', name='sysadm', value="users"))
00078         ret.append(html.INPUT(type='submit', name='recoverpass', value=_('Mail account data')))
00079         recoverpass_link =  unicode(unicode(ret))
00080 
00081         if account.email:
00082             email_link = (request.formatter.url(1, 'mailto:' + account.email, css='mailto') +
00083                           request.formatter.text(account.email) +
00084                           request.formatter.url(0))
00085         else:
00086             email_link = ''
00087 
00088         if account.jid:
00089             jabber_link = (request.formatter.url(1, 'xmpp:' + account.jid, css='mailto') +
00090                            request.formatter.text(account.jid) +
00091                            request.formatter.url(0))
00092         else:
00093             jabber_link = ''
00094 
00095         data.addRow((
00096             request.formatter.rawHTML(namelink),
00097             request.formatter.rawHTML(grouppage_links),
00098             email_link,
00099             jabber_link,
00100             recoverpass_link + enable_disable_link
00101         ))
00102 
00103     if data:
00104         from MoinMoin.widget.browser import DataBrowserWidget
00105 
00106         browser = DataBrowserWidget(request)
00107         browser.setData(data)
00108         return browser.render()
00109 
00110     # No data
00111     return ''
00112 

Here is the caller graph for this function: