Back to index

moin  1.9.0~rc2
userprofile.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - set values in user profile
00004 
00005     @copyright: 2008 MoinMoin:ThomasWaldmann
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 from MoinMoin.Page import Page
00009 from MoinMoin import user
00010 
00011 def execute(pagename, request):
00012     """ set values in user profile """
00013     _ = request.getText
00014     cfg = request.cfg
00015     form = request.form
00016 
00017     if not request.user.isSuperUser():
00018         request.theme.add_msg(_("Only superuser is allowed to use this action."), "error")
00019     else:
00020         user_name = form.get('name', '')
00021         key = form.get('key', '')
00022         val = form.get('val', '')
00023         if key in cfg.user_checkbox_fields:
00024             val = int(val)
00025         uid = user.getUserId(request, user_name)
00026         theuser = user.User(request, uid)
00027         oldval = getattr(theuser, key)
00028         setattr(theuser, key, val)
00029         theuser.save()
00030         request.theme.add_msg('%s.%s: %s -> %s' % (user_name, key, oldval, val), "info")
00031 
00032     Page(request, pagename).send_page()
00033