Browse Source

added first view for user registration

php2python
Holger Frey 7 years ago
parent
commit
1285202483
  1. 21
      ordr2/views/account.py

21
ordr2/views/account.py

@ -4,6 +4,7 @@ from pyramid.security import remember, forget @@ -4,6 +4,7 @@ from pyramid.security import remember, forget
from pyramid.view import view_config
from ordr2.models import User
from ordr2.schemas.account import RegistrationSchema
# user log in and log out
@ -12,7 +13,8 @@ from ordr2.models import User @@ -12,7 +13,8 @@ from ordr2.models import User
name='login',
permission='login',
request_method='GET',
renderer='ordr2:templates/account/login.jinja2')
renderer='ordr2:templates/account/login.jinja2'
)
def login_form(context, request):
''' display a login form '''
return {}
@ -22,7 +24,8 @@ def login_form(context, request): @@ -22,7 +24,8 @@ def login_form(context, request):
context='ordr2:resources.Account',
name='login',
permission='login',
request_method='POST')
request_method='POST'
)
def login(context, request):
''' loging in a user '''
username = request.POST.get('username')
@ -65,3 +68,17 @@ def logout(context, request): @@ -65,3 +68,17 @@ def logout(context, request):
request.resource_path(request.root, 'about'),
headers=headers
)
# user registration
@view_config(
context='ordr2:resources.Account',
name='register',
permission='register',
renderer='ordr2:templates/account/register.jinja2'
)
def registration_form(context, request):
context.nav_highlight = 'register'
form = RegistrationSchema.as_form(request)
return {'form': form}