Added the ability to specify a global demo login for testing purposes,
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 18 Jan 2008 22:07:24 +0000 (22:07 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 18 Jan 2008 22:07:24 +0000 (22:07 +0000)
so the manual ses=<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
Open-ILS/web/oilsweb/oilsweb/lib/__init__.py

index c74a48f..f95da19 100644 (file)
@@ -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
+
 
 
 
index 3e23557..7642c07 100644 (file)
@@ -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: