From c0976f4586945708d69ec9639fb999ccfce1a555 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 18 Jan 2008 22:07:24 +0000 Subject: [PATCH] Added the ability to specify a global demo login for testing purposes, so the manual ses= stop is not required git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8428 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/oilsweb/development.ini | 7 +++++++ Open-ILS/web/oilsweb/oilsweb/lib/__init__.py | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/oilsweb/development.ini b/Open-ILS/web/oilsweb/development.ini index c74a48f3e5..f95da199b3 100644 --- a/Open-ILS/web/oilsweb/development.ini +++ b/Open-ILS/web/oilsweb/development.ini @@ -59,6 +59,13 @@ oils_bib_cache_time = 3200 # path to extra templates or overridden templates local_templates = /openils/var/web/oilsweb/oilsweb/local_templates +# if uncommented, they system will login automatically using +# these credentials. Note that this user will either need to +# be an superuser or have appropriate ACQ perms +#oils_demo_user = demo-admin +#oils_demo_password = demo123 +#oils_demo_workstation = BR1-demo + diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py b/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py index 3e23557ea5..7642c07590 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py @@ -1,5 +1,5 @@ from oilsweb.lib.context import Context, SubContext, ContextItem -import osrf.ses, oils.utils.csedit, pylons.config +import osrf.ses, oils.utils.csedit, pylons.config, oils.utils.utils, oils.event from gettext import gettext as _ class AuthException(Exception): @@ -25,6 +25,7 @@ class CoreContext(SubContext): self.user = ContextItem() # logged in user object self.workstation = ContextItem() # workstation object self.page = ContextItem() # the current page + self.use_demo = ContextItem(cgi_name='demo') # use the demo login def postinit(self): self.prefix = pylons.config['oils_prefix'] @@ -36,8 +37,22 @@ class CoreContext(SubContext): self.fetchUser() + def doLogin(self): + if pylons.config.get('oils_demo_user'): + evt = oils.utils.utils.login( + pylons.config['oils_demo_user'], + pylons.config['oils_demo_password'], + 'staff', + pylons.config['oils_demo_workstation']) + oils.event.Event.parse_and_raise(evt) + self.authtoken = evt['payload']['authtoken'] + def fetchUser(self): ''' Grab the logged in user and their workstation ''' + + if not self.authtoken: + self.doLogin() + if self.authtoken: if self.authtoken in CoreContext._auth_cache: -- 2.11.0