currentfeature/docs
Last change
on this file since 78af3d1 was
1d92bf2,
checked in by borja <borja@…>, 5 years ago
|
(#37) Allow login using email address instead of username:
- Use user uids as keys in the root folder for referencing
user objects (instead of username)
- Use uids for referencing users all over the place (auth,
permissions, traversal urls, etc)
- Replaced the username concept with nickname. This nickname
will be used as a shortcut to access "public profile" pages
for users
- Reworked lots of basic methods in the OpenWorkouts root object
(s/username/nickname, marked as properties some methods like
users, emails, etc)
- Added new add_user() and delete_user() helpers to the OpenWorkouts
root object
- Fixed bug in the dashboard redirect view, causing an endless loop
if an authenticated user does not exist anymore when loading a
page.
- Lots of tests fixes, adaptations and catch up.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | from pyramid.view import view_config |
---|
2 | from pyramid_simpleform import Form, State |
---|
3 | from pyramid_simpleform.renderers import FormRenderer |
---|
4 | from pyramid.httpexceptions import HTTPFound |
---|
5 | |
---|
6 | from ..models.root import OpenWorkouts |
---|
7 | from ..models.user import User |
---|
8 | from ..schemas.user import UserAddSchema |
---|
9 | |
---|
10 | |
---|
11 | @view_config( |
---|
12 | context=OpenWorkouts, |
---|
13 | permission='edit', |
---|
14 | name='userlist', |
---|
15 | renderer='ow:templates/user_list.pt') |
---|
16 | def user_list(context, request): |
---|
17 | """ |
---|
18 | Show a list of all the users to admins |
---|
19 | """ |
---|
20 | users = context.users |
---|
21 | return {'users': users} |
---|
22 | |
---|
23 | |
---|
24 | @view_config( |
---|
25 | context=OpenWorkouts, |
---|
26 | permission='edit', |
---|
27 | name='adduser', |
---|
28 | renderer='ow:templates/add_user.pt') |
---|
29 | def add_user(context, request): |
---|
30 | """ |
---|
31 | Form to add a user |
---|
32 | """ |
---|
33 | state = State(emails=context.lowercase_emails, |
---|
34 | names=context.lowercase_nicknames) |
---|
35 | |
---|
36 | form = Form(request, schema=UserAddSchema(), state=state) |
---|
37 | |
---|
38 | if 'submit' in request.POST and form.validate(): |
---|
39 | user = form.bind(User()) |
---|
40 | context[str(user.uid)] = user |
---|
41 | return HTTPFound(location=request.resource_url(context, 'userlist')) |
---|
42 | |
---|
43 | return { |
---|
44 | 'form': FormRenderer(form) |
---|
45 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.