annotate MoinMoin/action/newaccount.py @ 2365:b9feee61d28e

split newaccount form from prefs
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 12 Jul 2007 11:40:04 +0200
parents 22749e92a461
children 58260d360f5c
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
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
46 # 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
47 if password != password2:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
48 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
49 if not password:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
50 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
51
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
52 # Encode password
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
53 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
54 try:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
55 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
56 except UnicodeError, err:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
57 # Should never happen
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
58 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
59
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
60 # 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
61 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
62 theuser.email = email.strip()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
63 if not theuser.email:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
64 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
65 " 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
66
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
67 # 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
68 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
69 users = user.getUserList(request)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
70 for uid in users:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
71 if uid == theuser.id:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
72 continue
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
73 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
74 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
75 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
76
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
77 # save data
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
78 theuser.save()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
79
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
80 user_created = events.UserCreatedEvent(request, theuser)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
81 events.send_event(user_created)
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 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
84 theuser.mailAccountData()
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 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
87 if _debug:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
88 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
89 return result
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
90
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
91
2365
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
92 def _create_form(request):
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
93 _ = request.getText
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
94 url = request.page.url(request)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
95 ret = html.FORM(action=url)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
96 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
97 lang_attr = request.theme.ui_lang_attr()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
98 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
99 tbl = html.TABLE(border="0")
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
100 ret.append(tbl)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
101 ret.append(html.Raw('</div>'))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
102
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
103 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
104 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
105 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
106 html.Text(_("Name")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
107 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
108 name="name")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
109
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
110 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
111 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
112 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
113 html.Text(_("Password")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
114 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
115 name="password")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
116
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
117 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
118 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
119 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
120 html.Text(_("Password repeat")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
121 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
122 name="password2")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
123
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
124 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
125 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
126 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
127 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
128 name="email")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
129
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
130 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
131 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
132 row.append(html.TD())
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
133 td = html.TD()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
134 row.append(td)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
135 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
136 value=_('Create Profile')))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
137 if request.cfg.mail_enabled:
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
138 td.append(html.Text(' '))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
139 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
140 value="%s + %s" % (_('Create Profile'),
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
141 _('Email'))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
142
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
143 return unicode(ret)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
144
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
145 def execute(pagename, request):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
146 pagename = pagename
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
147 page = Page(request, pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
148 _ = request.getText
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
149 form = request.form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
150
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
151 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
152
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
153 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
154 error = _create_user(request)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
155 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
156 else: # show create form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
157 request.emit_http_headers()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
158 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
159
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
160 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
161
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
162 # 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
163 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
164
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
165 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
166
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
167 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
168 request.theme.send_closing_html()