annotate MoinMoin/action/newaccount.py @ 2493:f3e3ffa68a7f

Send UserCreatedEvent from user.save(), not the newaccount action.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 22 Jul 2007 04:16:05 +0200
parents 58260d360f5c
children 78d96fd775ba
rev   line source
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
2 """
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
3 MoinMoin - create account action
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
4
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
5 @copyright: 2007 MoinMoin:JohannesBerg
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
7 """
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
8
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
9 from MoinMoin import user, wikiutil, util
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
10 from MoinMoin.Page import Page
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
11 from MoinMoin.widget import html
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
12 import MoinMoin.events as events
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
13
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
14
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
15 _debug = False
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
16
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
17 def _create_user(request):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
18 _ = request.getText
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
19 form = request.form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
20
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
21 if request.request_method != 'POST':
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
22 return _("Use UserPreferences to change your settings or create an account.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
23 # Create user profile
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
24 theuser = user.User(request, auth_method="new-user")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
25
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
26 # Require non-empty name
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
27 try:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
28 theuser.name = form['name'][0]
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
29 except KeyError:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
30 return _("Empty user name. Please enter a user name.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
31
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
32 # Don't allow creating users with invalid names
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
33 if not user.isValidName(request, theuser.name):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
34 return _("""Invalid user name {{{'%s'}}}.
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
35 Name may contain any Unicode alpha numeric character, with optional one
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
36 space between words. Group page name is not allowed.""") % wikiutil.escape(theuser.name)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
37
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
38 # Name required to be unique. Check if name belong to another user.
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
39 if user.getUserId(request, theuser.name):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
40 return _("This user name already belongs to somebody else.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
41
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
42 # try to get the password and pw repeat
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
43 password = form.get('password', [''])[0]
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
44 password2 = form.get('password2', [''])[0]
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
45
2431
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
46 pw_checker = request.cfg.password_checker
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
47 if pw_checker:
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
48 pw_error = pw_checker(theuser.name, password)
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
49 if pw_error:
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
50 return _("Password not acceptable: %s") % pw_error
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
51
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
52 # Check if password is given and matches with password repeat
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
53 if password != password2:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
54 return _("Passwords don't match!")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
55 if not password:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
56 return _("Please specify a password!")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
57
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
58 # Encode password
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
59 if password and not password.startswith('{SHA}'):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
60 try:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
61 theuser.enc_password = user.encodePassword(password)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
62 except UnicodeError, err:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
63 # Should never happen
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
64 return "Can't encode password: %s" % str(err)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
65
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
66 # try to get the email, for new users it is required
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
67 email = wikiutil.clean_input(form.get('email', [''])[0])
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
68 theuser.email = email.strip()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
69 if not theuser.email:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
70 return _("Please provide your email address. If you lose your"
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
71 " login information, you can get it by email.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
72
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
73 # Email should be unique - see also MoinMoin/script/accounts/moin_usercheck.py
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
74 if theuser.email and request.cfg.user_email_unique:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
75 users = user.getUserList(request)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
76 for uid in users:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
77 if uid == theuser.id:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
78 continue
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
79 thisuser = user.User(request, uid)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
80 if thisuser.email == theuser.email and not thisuser.disabled:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
81 return _("This email already belongs to somebody else.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
82
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
83 # save data
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
84 theuser.save()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
85
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
86 if form.has_key('create_and_mail'):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
87 theuser.mailAccountData()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
88
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
89 result = _("User account created! You can use this account to login now...")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
90 if _debug:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
91 result = result + util.dumpFormData(form)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
92 return result
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
93
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
94
2365
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
95 def _create_form(request):
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
96 _ = request.getText
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
97 url = request.page.url(request)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
98 ret = html.FORM(action=url)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
99 ret.append(html.INPUT(type='hidden', name='action', value='newaccount'))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
100 lang_attr = request.theme.ui_lang_attr()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
101 ret.append(html.Raw('<div class="userpref"%s>' % lang_attr))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
102 tbl = html.TABLE(border="0")
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
103 ret.append(tbl)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
104 ret.append(html.Raw('</div>'))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
105
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
106 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
107 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
108 row.append(html.TD().append(html.STRONG().append(
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
109 html.Text(_("Name")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
110 row.append(html.TD().append(html.INPUT(type="text", size="36",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
111 name="name")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
112
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
113 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
114 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
115 row.append(html.TD().append(html.STRONG().append(
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
116 html.Text(_("Password")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
117 row.append(html.TD().append(html.INPUT(type="password", size="36",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
118 name="password")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
119
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
120 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
121 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
122 row.append(html.TD().append(html.STRONG().append(
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
123 html.Text(_("Password repeat")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
124 row.append(html.TD().append(html.INPUT(type="password", size="36",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
125 name="password2")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
126
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
127 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
128 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
129 row.append(html.TD().append(html.STRONG().append(html.Text(_("Email")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
130 row.append(html.TD().append(html.INPUT(type="text", size="36",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
131 name="email")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
132
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
133 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
134 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
135 row.append(html.TD())
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
136 td = html.TD()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
137 row.append(td)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
138 td.append(html.INPUT(type="submit", name="create_only",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
139 value=_('Create Profile')))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
140 if request.cfg.mail_enabled:
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
141 td.append(html.Text(' '))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
142 td.append(html.INPUT(type="submit", name="create_and_mail",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
143 value="%s + %s" % (_('Create Profile'),
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
144 _('Email'))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
145
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
146 return unicode(ret)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
147
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
148 def execute(pagename, request):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
149 pagename = pagename
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
150 page = Page(request, pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
151 _ = request.getText
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
152 form = request.form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
153
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
154 submitted = form.has_key('create_only') or form.has_key('create_and_mail')
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
155
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
156 if submitted: # user pressed create button
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
157 error = _create_user(request)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
158 return page.send_page(msg=error)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
159 else: # show create form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
160 request.emit_http_headers()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
161 request.theme.send_title(_("Create Account"), pagename=pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
162
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
163 request.write(request.formatter.startContent("content"))
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
164
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
165 # THIS IS A BIG HACK. IT NEEDS TO BE CLEANED UP
2365
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
166 request.write(_create_form(request))
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
167
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
168 request.write(request.formatter.endContent())
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
169
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
170 request.theme.send_footer(pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
171 request.theme.send_closing_html()