Back to index

moin  1.9.0~rc2
Functions
MoinMoin.action.userprofile Namespace Reference

Functions

def execute

Function Documentation

def MoinMoin.action.userprofile.execute (   pagename,
  request 
)
set values in user profile 

Definition at line 11 of file userprofile.py.

00011 
00012 def execute(pagename, request):
00013     """ set values in user profile """
00014     _ = request.getText
00015     cfg = request.cfg
00016     form = request.form
00017 
00018     if not request.user.isSuperUser():
00019         request.theme.add_msg(_("Only superuser is allowed to use this action."), "error")
00020     else:
00021         user_name = form.get('name', '')
00022         key = form.get('key', '')
00023         val = form.get('val', '')
00024         if key in cfg.user_checkbox_fields:
00025             val = int(val)
00026         uid = user.getUserId(request, user_name)
00027         theuser = user.User(request, uid)
00028         oldval = getattr(theuser, key)
00029         setattr(theuser, key, val)
00030         theuser.save()
00031         request.theme.add_msg('%s.%s: %s -> %s' % (user_name, key, oldval, val), "info")
00032 
00033     Page(request, pagename).send_page()
00034