annotate MoinMoin/action/userprofile.py @ 5952:f6a74810da73

updated CHANGES
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 10 Mar 2013 15:28:04 +0100
parents bf0b4b96dcb4
children
rev   line source
2984
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - set values in user profile
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 @copyright: 2008 MoinMoin:ThomasWaldmann
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 """
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8 from MoinMoin.Page import Page
5486
a283079b3f1e userprofile action: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
9 from MoinMoin import user, wikiutil
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2984
diff changeset
10
2984
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 def execute(pagename, request):
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 """ set values in user profile """
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 _ = request.getText
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 cfg = request.cfg
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 form = request.form
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 if not request.user.isSuperUser():
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 request.theme.add_msg(_("Only superuser is allowed to use this action."), "error")
5488
b0dfed9a569f merged moin/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4201 5486
diff changeset
19 elif (request.method == 'POST' and
b0dfed9a569f merged moin/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4201 5486
diff changeset
20 wikiutil.checkTicket(request, form.get('ticket', ''))):
4201
40acd13fb3d6 Changed form access to MultiDict forms
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3070
diff changeset
21 user_name = form.get('name', '')
40acd13fb3d6 Changed form access to MultiDict forms
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3070
diff changeset
22 key = form.get('key', '')
40acd13fb3d6 Changed form access to MultiDict forms
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3070
diff changeset
23 val = form.get('val', '')
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2984
diff changeset
24 if key in cfg.user_checkbox_fields:
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2984
diff changeset
25 val = int(val)
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2984
diff changeset
26 uid = user.getUserId(request, user_name)
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2984
diff changeset
27 theuser = user.User(request, uid)
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2984
diff changeset
28 oldval = getattr(theuser, key)
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2984
diff changeset
29 setattr(theuser, key, val)
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2984
diff changeset
30 theuser.save()
5685
37306fba2189 Fixing security issues related to MoinMoinBugs/1.9.2UnescapedInputForThemeAddMsg (possible XSS)
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5486
diff changeset
31 request.theme.add_msg('%s.%s: %s -> %s' % tuple([wikiutil.escape(s) for s in [user_name, key, oldval, val]]), "info")
2984
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 Page(request, pagename).send_page()
52f9d511f155 SystemAdmin user browser: SuperUser now can enable/disable user accounts, new userprofile action (partly a port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34