repaired some labels. gave org-tree widget ability to disable orgs below a certain...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Feb 2008 17:48:50 +0000 (17:48 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 4 Feb 2008 17:48:50 +0000 (17:48 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8608 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py
Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_source.html
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/navigate.html
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html

index 9400986..ea31dc1 100644 (file)
@@ -38,7 +38,19 @@ class FundSourceController(BaseController):
             source_id = fund_mgr.create_fund_source(source)
             return redirect_to(controller='acq/fund_source', action='view', id=source_id)
 
-        r.ctx.acq.currency_types = fund_mgr.fetch_currency_types()
+        perm_orgs = osrf.ses.ClientSession.atomic_request(
+            'open-ils.actor',
+            'open-ils.actor.user.work_perm.highest_org_set',
+            r.ctx.core.authtoken, 'CREATE_FUNDING_SOURCE');
+
+        if len(perm_orgs) == 0:
+            return _("Insufficient Permissions") # XXX Return a perm failure template
+
         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.acq.currency_types = fund_mgr.fetch_currency_types()
         return r.render('acq/financial/create_fund_source.html')
 
+
+
index b4e2c9c..f9ca5d0 100644 (file)
@@ -28,6 +28,12 @@ class CoreContext(SubContext):
         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={})
+
+        # place to store slim perm org trees
+        self.perm_tree = ContextItem(default_value={})
+
     def postinit(self):
         self.prefix = pylons.config['oils_prefix']
         self.media_prefix = pylons.config['oils_media_prefix']
@@ -65,6 +71,17 @@ class CoreContext(SubContext):
                 '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())
@@ -90,6 +107,9 @@ class UtilContext(SubContext):
     def __init__(self):
         import oilsweb.lib.bib
         self.scrub_isbn = ContextItem(default_value=oilsweb.lib.bib.scrub_isbn)
+        self.get_org_type = ContextItem(default_value=oils.org.OrgUtil.get_org_type)
+        self.get_min_org_depth = ContextItem(default_value=oils.org.OrgUtil.get_min_depth)
 
 Context.applySubContext('util', UtilContext)
 
+
index 36f20da..f2d1f25 100644 (file)
@@ -1,27 +1,30 @@
 # -*- coding: utf-8 -*-
+<!-- vim:set filetype=mako: -->
 <%inherit file='../base.html'/>
 <%namespace file='../../common/widgets.html' name='widget'/>
-<%def name="page_title()">${_('Evergreen Create Fund')}</%def>
+<%def name="page_title()">${_('Create Fund Source')}</%def>
 <%def name="block_content()">
 
 <form action='${c.oils.acq.prefix}/fund_source/create' method='POST'>
     <table class='oils-admin-table'>
         <tbody>
             <tr>
-                <td class='oils-admin-label'>${_('Fund Name')}</td>
+                <td class='oils-admin-label'>${_('Fund Source Name')}</td>
                 <td> 
                     <input type='text' size='42' name='${c.oils.acq.fund_source_name_.cgi_name}'/>
                 </td>
             </tr>
             <tr>
-                <td class='oils-admin-label'>${_('Fund Onwer')}</td>
+                <td class='oils-admin-label'>${_('Fund Source Onwer')}</td>
                 <td> 
-                    ${widget.org_select(c.oils.acq.fund_source_owner_.cgi_name)}
-                    <b>* ADD PERM FILTER HERE *</b>
+                    ${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']))}
                 </td>
             </tr>
             <tr>
-                <td class='oils-admin-label'>${_('Fund Currency Type')}</td>
+                <td class='oils-admin-label'>${_('Fund Source Currency Type')}</td>
                 <td> 
                     <select name='${c.oils.acq.fund_source_currency_type_.cgi_name}'>
                         % for type in c.oils.acq.currency_types:
@@ -32,7 +35,7 @@
             </tr>
             <tr>
                 <td colspan='2'>
-                    <input type='submit' value='${_("Create Fund")}'/>
+                    <input type='submit' value='${_("Create Fund Source")}'/>
                 </td>
             </tr>
         </tbody>
index cc1df2f..672b305 100644 (file)
@@ -1,15 +1,15 @@
 # -*- coding: utf-8 -*-
 <%inherit file='../base.html'/>
 <%namespace file='../../common/widgets.html' name='widget'/>
-<%def name="page_title()">${_('Evergreen Create Fund')}</%def>
+<%def name="page_title()">${_('Create Fund Source')}</%def>
 <%def name="block_content()">
 
 <table class='oils-admin-table'>
     <thead>
         <tr>
-            <td>${_('Fund Name')}</td>
-            <td>${_('Fund Owner')}</td>
-            <td>${_('Fund Currency Type')}</td>
+            <td>${_('Fund Source Name')}</td>
+            <td>${_('Fund Source Owner')}</td>
+            <td>${_('Fund Source Currency Type')}</td>
         </tr>
     </thead>
     <tbody>
index a66b86b..aee41d9 100644 (file)
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 <div class='oils-base-navigate-item'>
-    <a href='${c.oils.core.prefix}/acq/fund_source/list'>${_('My Fund Sources')}</a>
+    <a href='${c.oils.core.prefix}/acq/fund_source/list'>${_('Fund Sources')}</a>
 </div>
 <div class='oils-base-navigate-item'>
-    <a href='${c.oils.core.prefix}/acq/fund_source/create'>${_('Create Fund Source')}</a>
+    <a href='${c.oils.core.prefix}/acq/fund_source/create'>${_('New Fund Source')}</a>
 </div>
    
index 1266e63..ee9078f 100644 (file)
@@ -1,22 +1,22 @@
 # -*- coding: utf-8 -*-
 <%inherit file='../base.html'/>
 <%namespace file='../../common/widgets.html' name='widget'/>
-<%def name="page_title()">${_('Evergreen Create Fund')}</%def>
+<%def name="page_title()">${_('Create Fund Source')}</%def>
 <%def name="block_content()">
 
 <form action='${c.oils.acq.prefix}/fund_source/create' method='POST'>
     <table class='oils-admin-table'>
         <tbody>
             <tr>
-                <td class='oils-admin-label'>${_('Fund Name')}</td>
+                <td class='oils-admin-label'>${_('Fund Source Name')}</td>
                 <td>${c.oils.acq.fund_source.name()}</td>
             </tr>
             <tr>
-                <td class='oils-admin-label'>${_('Fund Onwer')}</td>
+                <td class='oils-admin-label'>${_('Fund Source Onwer')}</td>
                 <td>${c.oils.acq.fund_source.owner().name()}</td> 
             </tr>
             <tr>
-                <td class='oils-admin-label'>${_('Fund Currency Type')}</td>
+                <td class='oils-admin-label'>${_('Fund Source Currency Type')}</td>
                 <td>${c.oils.acq.fund_source.currency_type()}</td> 
             </tr>
         </tbody>
index 518dc7b..5a65f2c 100644 (file)
@@ -11,7 +11,7 @@
     </div>
 % endif
 <div class='oils-base-navigate-item'>
-    <a href='${c.oils.core.prefix}/acq/fundsource/list'>${_('Funds')}</a>
+    <a href='${c.oils.core.prefix}/acq/fund_source/list'>${_('Funds')}</a>
     <!--
     <a href='${c.oils.core.prefix}/acq/fund/list'>${_('Funds')}</a>
     -->
index 3829fbe..0a2fcbb 100644 (file)
@@ -4,11 +4,14 @@
     Define some common widgets 
 -->
 
-<%def name='org_draw_node(node, indent=0, selected=None)'>
+<%def name='org_draw_node(node, indent=0, selected=None, disable_depth=-1)'>
     <option value='${node.id()}'
     % if selected == node.id():
         selected='selected'
-    %endif
+    % endif
+    % if c.oils.util.get_org_type(node).depth() < disable_depth:
+        disabled='disabled'
+    % endif
     >
         % for i in range(indent):
             &#160;&#160;
@@ -22,7 +25,7 @@
         
 </%def>
 
-<%def name='org_select(select_name, tree=None, selected=None)'>
+<%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 -->
     <%
@@ -30,6 +33,6 @@
             tree = c.oils.core.org_tree
     %>
     <select name='${select_name}'>
-        ${org_draw_node(tree, 0, selected)}
+        ${org_draw_node(tree, 0, selected, disable_depth)}
     </select>
 </%def>