[open-ils-commits] SPAM: r8622 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers/acq lib lib/acq templates/oils/default/acq/financial
templates/oils/default/common
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 4 19:28:08 EST 2008
Author: erickson
Date: 2008-02-04 18:59:54 -0500 (Mon, 04 Feb 2008)
New Revision: 8622
Added:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/user.py
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_source.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html
Log:
more permission work with funding sources
some label changes
pulled the user code out into its own module
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py 2008-02-04 23:54:35 UTC (rev 8621)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py 2008-02-04 23:59:54 UTC (rev 8622)
@@ -48,7 +48,7 @@
r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree()
r.ctx.core.perm_tree['CREATE_FUNDING_SOURCE'] = oils.org.OrgUtil.get_union_tree(perm_orgs)
- r.ctx.core.perm_orgs['CREATE_FUNDING_SOURCE'] = perm_orgs
+ r.ctx.core.high_perm_orgs['CREATE_FUNDING_SOURCE'] = perm_orgs
r.ctx.acq.currency_types = fund_mgr.fetch_currency_types()
return r.render('acq/financial/create_fund_source.html')
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py 2008-02-04 23:54:35 UTC (rev 8621)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py 2008-02-04 23:59:54 UTC (rev 8622)
@@ -1,20 +1,10 @@
from oilsweb.lib.context import Context, SubContext, ContextItem
import osrf.ses, oils.utils.csedit, pylons.config, oils.utils.utils, oils.event
+import oilsweb.lib.user
from gettext import gettext as _
-class AuthException(Exception):
- def __init__(self, info=''):
- self.info = info
- def __str__(self):
- return "%s: %s" % (self.__class__.__name__, unicode(self.info))
-
-
-
class CoreContext(SubContext):
-
# cache the authenticated user info
- _auth_cache = {}
-
def __init__(self):
self.prefix = ContextItem() # web prefix
self.media_prefix = ContextItem() # media prefix
@@ -28,9 +18,11 @@
self.org_tree = ContextItem() # full org tree
self.page = ContextItem() # the current page
- # place to store perm org sets
- self.perm_orgs = ContextItem(default_value={})
+ self.work_orgs = ContextItem()
+ # place to store perm org sets for a given permission
+ self.high_perm_orgs = ContextItem(default_value={})
+
# place to store slim perm org trees
self.perm_tree = ContextItem(default_value={})
@@ -38,67 +30,12 @@
self.prefix = pylons.config['oils_prefix']
self.media_prefix = pylons.config['oils_media_prefix']
self.ac_prefix = pylons.config['oils_added_content_prefix']
-
self.skin = 'default' # XXX
self.theme = 'default' # XXX
+ usermgr = oilsweb.lib.user.User(self)
+ usermgr.fetch_user()
+ #self.work_orgs = usermgr.fetch_work_orgs()
- 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:
- self.user = CoreContext._auth_cache[self.authtoken]['user']
- self.workstation = CoreContext._auth_cache[self.authtoken]['workstation']
- return
-
- self.user = osrf.ses.ClientSession.atomic_request(
- 'open-ils.auth',
- 'open-ils.auth.session.retrieve', self.authtoken)
-
- evt = oils.event.Event.parse_event(self.user)
- if evt and evt.text_code == 'NO_SESSION':
- # our authtoken has timed out. If we have the ability
- # to loin, go ahead and try
- self.doLogin()
- self.user = osrf.ses.ClientSession.atomic_request(
- 'open-ils.auth',
- 'open-ils.auth.session.retrieve', self.authtoken)
- oils.event.Event.parse_and_raise(self.user)
-
-
- if not self.user:
- raise AuthException(_('No user found with authtoken %(self.authtoken)s'))
- self.workstation = oils.utils.csedit.CSEditor().retrieve_actor_workstation(self.user.wsid())
-
- if not self.workstation:
- raise AuthException(_('No workstation found'))
-
- # cache the auth data and destroy any old auth data
- CoreContext._auth_cache = {
- self.authtoken : {
- 'user' : self.user,
- 'workstation' : self.workstation
- }
- }
- else:
- raise AuthException(_('No authentication token provided'))
-
Context.applySubContext('core', CoreContext)
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py 2008-02-04 23:54:35 UTC (rev 8621)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py 2008-02-04 23:59:54 UTC (rev 8622)
@@ -51,9 +51,7 @@
def retrieve_org_fund_sources(self):
sources = self.ses.request(
'open-ils.acq.funding_source.org.retrieve',
- self.request_mgr.ctx.core.authtoken,
- self.request_mgr.ctx.core.workstation.owning_lib(),
- {"full_path":1}).recv().content()
+ self.request_mgr.ctx.core.authtoken).recv().content()
oils.event.Event.parse_and_raise(sources)
return sources
Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/user.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/user.py (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/user.py 2008-02-04 23:59:54 UTC (rev 8622)
@@ -0,0 +1,63 @@
+import osrf.ses, oils.utils.csedit, pylons.config, oils.utils.utils, oils.event
+from gettext import gettext as _
+
+class AuthException(Exception):
+ def __init__(self, info=''):
+ self.info = info
+ def __str__(self):
+ return "%s: %s" % (self.__class__.__name__, unicode(self.info))
+
+class User(object):
+ ''' General purpose user utility methods '''
+
+ def __init__(self, ctx):
+ self.ctx = ctx
+
+ def try_auto_login(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.ctx.authtoken = evt['payload']['authtoken']
+
+ def fetch_user(self):
+ ''' Grab the logged in user and their workstation '''
+
+ if not self.ctx.authtoken:
+ self.try_auto_login()
+
+ if not self.ctx.authtoken:
+ raise AuthException(_('No authentication token provided'))
+
+ self.ctx.user = osrf.ses.ClientSession.atomic_request(
+ 'open-ils.auth',
+ 'open-ils.auth.session.retrieve', self.ctx.authtoken)
+
+ evt = oils.event.Event.parse_event(self.ctx.user)
+ if evt and evt.text_code == 'NO_SESSION':
+ # our authtoken has timed out. See if we can autologin
+ self.try_auto_login()
+ if not self.ctx.authtoken:
+ raise AuthException(_('No authentication token provided'))
+ self.ctx.user = osrf.ses.ClientSession.atomic_request(
+ 'open-ils.auth',
+ 'open-ils.auth.session.retrieve', self.ctx.authtoken)
+ oils.event.Event.parse_and_raise(self.ctx.user)
+
+ self.ctx.workstation = oils.utils.csedit.CSEditor().retrieve_actor_workstation(self.ctx.user.wsid())
+ if not self.ctx.workstation:
+ raise AuthException(_('No workstation found'))
+
+ def fetch_work_orgs(self):
+ work_orgs = osrf.ses.ClientSession.atomic_request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.get_work_ous.ids',
+ self.ctx.authtoken)
+ oils.event.Event.parse_and_raise(work_orgs)
+ return work_orgs
+
+
+
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_source.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_source.html 2008-02-04 23:54:35 UTC (rev 8621)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_source.html 2008-02-04 23:59:54 UTC (rev 8622)
@@ -20,7 +20,7 @@
${widget.org_select(
c.oils.acq.fund_source_owner_.cgi_name,
c.oils.core.perm_tree['CREATE_FUNDING_SOURCE'], c.oils.core.workstation.id(),
- c.oils.util.get_min_org_depth(c.oils.core.perm_orgs['CREATE_FUNDING_SOURCE']))}
+ c.oils.util.get_min_org_depth(c.oils.core.high_perm_orgs['CREATE_FUNDING_SOURCE']))}
</td>
</tr>
<tr>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html 2008-02-04 23:54:35 UTC (rev 8621)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html 2008-02-04 23:59:54 UTC (rev 8622)
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
<%inherit file='../base.html'/>
<%namespace file='../../common/widgets.html' name='widget'/>
-<%def name="page_title()">${_('Create Fund Source')}</%def>
+<%def name="page_title()">${_('Fund Sources')}</%def>
<%def name="block_content()">
<table class='oils-admin-table'>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html 2008-02-04 23:54:35 UTC (rev 8621)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html 2008-02-04 23:59:54 UTC (rev 8622)
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
<%inherit file='../base.html'/>
<%namespace file='../../common/widgets.html' name='widget'/>
-<%def name="page_title()">${_('Create Fund Source')}</%def>
+<%def name="page_title()">${_('View Fund Source')}</%def>
<%def name="block_content()">
<form action='${c.oils.acq.prefix}/fund_source/create' method='POST'>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html 2008-02-04 23:54:35 UTC (rev 8621)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html 2008-02-04 23:59:54 UTC (rev 8622)
@@ -26,8 +26,14 @@
</%def>
<%def name='org_select(select_name, tree=None, selected=None, disable_depth=-1)'>
- <!-- Draws a select dropdown of the org tree provided
- with indentation based on org depth -->
+ <!--
+ Draws a select dropdown of the org tree provided with indentation based on org depth.
+ @param select_name The form name for the select object
+ @param tree The org tree to draw
+ @param selected The ID of the org whose <option> to mark as selected
+ @param disable_depth Any orgs in the tree whose depth is less than disable_depth
+ will have their <options>'s disabled with disabled='disabled'
+ -->
<%
if tree is None:
tree = c.oils.core.org_tree
More information about the open-ils-commits
mailing list