From a1291e577406ffba7ba68031e827b334e7557668 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Wed, 27 Sep 2017 11:29:59 +0200 Subject: [PATCH] redirect default view depending on user login --- ordr2/views/pages.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ordr2/views/pages.py b/ordr2/views/pages.py index c9d0349..c4a6140 100644 --- a/ordr2/views/pages.py +++ b/ordr2/views/pages.py @@ -1,13 +1,24 @@ -from pyramid.response import Response +from pyramid.httpexceptions import HTTPFound from pyramid.view import view_config @view_config( context='ordr2.resources.Root', + permission='view' + ) +def welcome(context, request): + next = 'orders' if request.user else 'about' + redirect_to = request.resource_url(context, next) + return HTTPFound(redirect_to) + + +@view_config( + context='ordr2.resources.Root', + name='about', permission='view', renderer='ordr2:templates/pages/welcome.jinja2' ) -def welcome(context, request): +def about(context, request): return {}