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