diff --git a/ordr2/events.py b/ordr2/events.py new file mode 100644 index 0000000..411f4ee --- /dev/null +++ b/ordr2/events.py @@ -0,0 +1,19 @@ +from pyramid.events import subscriber + + +class UserLogIn(object): + def __init__(self, request, user): + self.request = request + self.user = user + + +@subscriber(UserLogIn) +def set_display_defaults(event): + defaults = { + 'users': { + 'first': True, + 'last': True, + 'email': True, + } + } + event.request.session['display'] = defaults diff --git a/ordr2/views/account.py b/ordr2/views/account.py index f38ecb5..f8a284a 100644 --- a/ordr2/views/account.py +++ b/ordr2/views/account.py @@ -5,6 +5,7 @@ from pyramid.renderers import render from pyramid.security import remember, forget from pyramid.view import view_config +from ordr2.events import UserLogIn from ordr2.models import User, Role from ordr2.schemas.account import RegistrationSchema, SettingsSchema @@ -39,6 +40,8 @@ def login(context, request): if user is not None: if user.is_active and user.check_password(password): headers = remember(request, user.id) + event = UserLogIn(request, user) + request.registry.notify(event) return HTTPFound( request.resource_path(request.root, 'orders'), headers=headers