[open-ils-commits] SPAM: r8734 - in branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb: controllers/acq templates/oils/default/acq/financial

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Feb 12 13:33:28 EST 2008


Author: erickson
Date: 2008-02-12 13:04:08 -0500 (Tue, 12 Feb 2008)
New Revision: 8734

Added:
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_funding_source_credit.html
Modified:
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html
Log:
added ability to create a funding_source_credit.  some minor code cleanup

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py	2008-02-12 18:02:42 UTC (rev 8733)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py	2008-02-12 18:04:08 UTC (rev 8734)
@@ -47,10 +47,13 @@
         self.fund_summary = ContextItem()
 
         self.fund_source = ContextItem()
+        self.fund_source_id = ContextItem(cgi_name='acq.fsi')
         self.fund_source_list = ContextItem()
         self.fund_source_name = ContextItem(cgi_name='acq.fsn')
         self.fund_source_currency_type = ContextItem(cgi_name='acq.fsc')
         self.fund_source_owner = ContextItem(cgi_name='acq.fso')
+        self.fund_source_credit_amount = ContextItem(cgi_name='acq.fsca')
+        self.fund_source_credit_note = ContextItem(cgi_name='acq.fscn')
 
 
         self.fund_allocation = ContextItem()

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py	2008-02-12 18:02:42 UTC (rev 8733)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py	2008-02-12 18:04:08 UTC (rev 8734)
@@ -2,25 +2,29 @@
 import pylons
 from oilsweb.lib.request import RequestMgr
 import oilsweb.lib.acq.fund, oilsweb.lib.user
-import osrf.net_obj, osrf.ses
-import oils.org, oils.const, oils.event
+import osrf.net_obj
+import oils.const
+from osrf.ses import ClientSession
+from oils.event import Event
+from oils.org import OrgUtil
 
+
 class FundController(BaseController):
 
     def _retrieve_fund(self, r, ses, fund_id):
         ''' Retrieves a fund object with summary and fleshse the org field '''
         fund = ses.request('open-ils.acq.fund.retrieve', 
             r.ctx.core.authtoken, fund_id, {"flesh_summary":1}).recv().content()
-        oils.event.Event.parse_and_raise(fund)
-        fund.org(oils.org.OrgUtil.get_org_unit(fund.org())) # flesh the org
+        Event.parse_and_raise(fund)
+        fund.org(OrgUtil.get_org_unit(fund.org())) # flesh the org
         return fund
 
 
     def view(self, **kwargs):
         r = RequestMgr()
-        r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree()
+        r.ctx.core.org_tree = OrgUtil.fetch_org_tree()
         fund_id = kwargs['id']
-        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
+        ses = ClientSession(oils.const.OILS_APP_ACQ)
 
         # grab the fund object
         fund = self._retrieve_fund(r, ses, fund_id)
@@ -29,20 +33,20 @@
 
     def list(self):
         r = RequestMgr()
-        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
+        ses = ClientSession(oils.const.OILS_APP_ACQ)
         funds = ses.request(
             'open-ils.acq.fund.org.retrieve', 
             r.ctx.core.authtoken, None, {"flesh_summary":1}).recv().content()
-        oils.event.Event.parse_and_raise(funds)
+        Event.parse_and_raise(funds)
         for f in funds:
-            f.org(oils.org.OrgUtil.get_org_unit(f.org()))
+            f.org(OrgUtil.get_org_unit(f.org()))
         r.ctx.acq.fund_list = funds
         return r.render('acq/financial/list_funds.html')
             
 
     def create(self):
         r = RequestMgr()
-        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
+        ses = ClientSession(oils.const.OILS_APP_ACQ)
 
         if r.ctx.acq.fund_name: # create then display the fund
 
@@ -54,7 +58,7 @@
 
             fund_id = ses.request('open-ils.acq.fund.create', 
                 r.ctx.core.authtoken, fund).recv().content()
-            oils.event.Event.parse_and_raise(fund_id)
+            Event.parse_and_raise(fund_id)
 
             return redirect_to(controller='acq/fund', action='view', id=fund_id)
 
@@ -64,7 +68,7 @@
         types = ses.request(
             'open-ils.acq.currency_type.all.retrieve',
             r.ctx.core.authtoken).recv().content()
-        r.ctx.acq.currency_types = oils.event.Event.parse_and_raise(types)
+        r.ctx.acq.currency_types = Event.parse_and_raise(types)
 
 
         if tree is None:
@@ -74,7 +78,7 @@
 
     def allocate(self):
         r = RequestMgr()
-        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
+        ses = ClientSession(oils.const.OILS_APP_ACQ)
 
         if r.ctx.acq.fund_allocation_source:
             return self._allocate(r, ses)
@@ -84,7 +88,7 @@
         source_list = ses.request(
             'open-ils.acq.funding_source.org.retrieve', 
             r.ctx.core.authtoken, None, {'limit_perm':'MANAGE_FUNDING_SOURCE', 'flesh_summary':1}).recv().content()
-        oils.event.Event.parse_and_raise(source_list)
+        Event.parse_and_raise(source_list)
 
         r.ctx.acq.fund = fund
         r.ctx.acq.fund_source_list = source_list
@@ -105,7 +109,7 @@
 
         alloc_id = ses.request(
             'open-ils.acq.fund_allocation.create', r.ctx.core.authtoken, alloc).recv().content()
-        oils.event.Event.parse_and_raise(alloc_id)
+        Event.parse_and_raise(alloc_id)
 
         return redirect_to(controller='acq/fund', action='view', id=r.ctx.acq.fund_allocation_fund)
 

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-12 18:02:42 UTC (rev 8733)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py	2008-02-12 18:04:08 UTC (rev 8734)
@@ -3,38 +3,41 @@
 from oilsweb.lib.request import RequestMgr
 import oilsweb.lib.acq.fund
 import osrf.net_obj
-import oils.org, oils.event, oils.const
+import oils.const
+from osrf.ses import ClientSession
+from oils.event import Event
+from oils.org import OrgUtil
 
 
 class FundSourceController(BaseController):
 
     def view(self, **kwargs):
         r = RequestMgr()
-        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
-        r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree()
+        ses = ClientSession(oils.const.OILS_APP_ACQ)
+        r.ctx.core.org_tree = OrgUtil.fetch_org_tree()
 
         source = ses.request(
             'open-ils.acq.funding_source.retrieve', 
             r.ctx.core.authtoken, kwargs.get('id'), {"flesh_summary":1}).recv().content()
-        oils.event.Event.parse_and_raise(source)
+        Event.parse_and_raise(source)
 
-        source.owner(oils.org.OrgUtil.get_org_unit(source.owner())) # flesh the owner
+        source.owner(OrgUtil.get_org_unit(source.owner())) # flesh the owner
         r.ctx.acq.fund_source = source
         return r.render('acq/financial/view_fund_source.html')
 
     def list(self):
         r = RequestMgr()
-        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
+        ses = ClientSession(oils.const.OILS_APP_ACQ)
 
         sources = ses.request(
             'open-ils.acq.funding_source.org.retrieve', 
             r.ctx.core.authtoken, None, {"flesh_summary":1}).recv().content()
 
-        oils.event.Event.parse_and_raise(sources)
+        Event.parse_and_raise(sources)
         r.ctx.acq.fund_source_list = sources
 
         for source in sources:
-            source.owner(oils.org.OrgUtil.get_org_unit(source.owner()))
+            source.owner(OrgUtil.get_org_unit(source.owner()))
         return r.render('acq/financial/list_fund_sources.html')
             
 
@@ -50,7 +53,7 @@
             source_id = fund_mgr.create_fund_source(source)
             return redirect_to(controller='acq/fund_source', action='view', id=source_id)
 
-        perm_orgs = osrf.ses.ClientSession.atomic_request(
+        perm_orgs = ClientSession.atomic_request(
             'open-ils.actor',
             'open-ils.actor.user.work_perm.highest_org_set',
             r.ctx.core.authtoken, 'CREATE_FUNDING_SOURCE');
@@ -58,10 +61,33 @@
         if len(perm_orgs) == 0:
             return _("Insufficient Permissions") # XXX Return a perm failure template
 
-        r.ctx.core.perm_tree['CREATE_FUNDING_SOURCE'] = oils.org.OrgUtil.get_union_tree(perm_orgs)
+        r.ctx.core.perm_tree['CREATE_FUNDING_SOURCE'] = OrgUtil.get_union_tree(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')
 
 
+    def create_credit(self):
+        r = RequestMgr()
+        ses = ClientSession(oils.const.OILS_APP_ACQ)
 
+        if r.ctx.acq.fund_source_credit_amount:
+
+            credit = osrf.net_obj.NetworkObject.acqfscred()
+            credit.funding_source(r.ctx.acq.fund_source_id)
+            credit.amount(r.ctx.acq.fund_source_credit_amount)
+            credit.note(r.ctx.acq.fund_source_credit_note)
+
+            status = ses.request(
+                'open-ils.acq.funding_source_credit.create',
+                r.ctx.core.authtoken, credit).recv().content()
+            status = Event.parse_and_raise(status)
+            return redirect_to(controller='acq/fund_source', action='view', id=r.ctx.acq.fund_source_id)
+
+        source = ses.request('open-ils.acq.funding_source.retrieve',
+            r.ctx.core.authtoken, r.ctx.acq.fund_source_id, {"flesh_summary":1}).recv().content()
+        r.ctx.acq.fund_source = Event.parse_and_raise(source)
+        source.owner(OrgUtil.get_org_unit(source.owner()))
+        return r.render('acq/financial/create_funding_source_credit.html')
+
+        

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py	2008-02-12 18:02:42 UTC (rev 8733)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py	2008-02-12 18:04:08 UTC (rev 8734)
@@ -3,10 +3,13 @@
 import logging, pylons
 import oilsweb.lib.context, oilsweb.lib.util
 import oilsweb.lib.bib, oilsweb.lib.acq.search, oilsweb.lib.acq.picklist
-import osrf.cache, osrf.json, osrf.ses
-import oils.const, oils.utils.utils, oils.event
+import oils.const, oils.utils.utils
+from osrf.ses import ClientSession
+from oils.event import Event
+from oils.org import OrgUtil
 
 
+
 class PicklistController(BaseController):
 
     def view(self, **kwargs):
@@ -24,10 +27,10 @@
             picklist = osrf.net_obj.NetworkObject.acqpl()
             picklist.name(r.ctx.acq.picklist_name)
             picklist.owner(r.ctx.core.user.id())
-            picklist_id = osrf.ses.ClientSession.atomic_request(
+            picklist_id = ClientSession.atomic_request(
                 oils.const.OILS_APP_ACQ,
                 'open-ils.acq.picklist.create', r.ctx.core.authtoken, picklist)
-            oils.event.Event.parse_and_raise(picklist_id)
+            Event.parse_and_raise(picklist_id)
             return redirect_to(controller='acq/picklist', action='view', id=picklist_id)
         return r.render('acq/picklist/create.html')
 
@@ -87,14 +90,16 @@
 
     def update(self):
         r = RequestMgr()
-        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
+        ses = ClientSession(oils.const.OILS_APP_ACQ)
         ses.connect()
 
+        page = redirect_to(controller='acq/picklist', action='list')
+
         if r.ctx.acq.picklist_action == 'move_selected':
-            self._move_selected(r, ses)
+            page = self._move_selected(r, ses)
 
         ses.disconnect()
-        return redirect_to(controller='acq/picklist', action='list')
+        return page
 
     def _move_selected(self, r, ses):
         ''' Moves the selected picklist entry's to the destination picklist '''
@@ -103,13 +108,15 @@
             entry = ses.request(
                 'open-ils.acq.picklist_entry.retrieve',
                 r.ctx.core.authtoken, entry_id).recv().content()
-            entry = oils.event.Event.parse_and_raise(entry)
+            entry = Event.parse_and_raise(entry)
 
             entry.picklist(r.ctx.acq.picklist_dest_id)
 
             status = ses.request(
                 'open-ils.acq.picklist_entry.update',
                 r.ctx.core.authtoken, entry).recv().content()
-            oils.event.Event.parse_and_raise(status)
+            Event.parse_and_raise(status)
 
+        return redirect_to(controller='acq/picklist', action='view', id=r.ctx.acq.picklist_dest_id)
 
+

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html	2008-02-12 18:02:42 UTC (rev 8733)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html	2008-02-12 18:04:08 UTC (rev 8734)
@@ -36,7 +36,7 @@
             <tr>
                 <td class='oils-admin-label'>${_('Fund Year')}</td>
                 <td> 
-                    <input type='text' size='42' year='${c.oils.acq.fund_year_.cgi_name}'/>
+                    <input type='text' size='42' name='${c.oils.acq.fund_year_.cgi_name}'/>
                 </td>
             </tr>
 

Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_funding_source_credit.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_funding_source_credit.html	                        (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_funding_source_credit.html	2008-02-12 18:04:08 UTC (rev 8734)
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+<!-- 
+ vim:ft=mako: 
+-->
+<%inherit file='../base.html'/>
+<%namespace file='../../common/widgets.html' name='widget'/>
+<%def name="page_title()">${_('Create Funding Source Credit')}</%def>
+<%def name="block_content()">
+
+<% source = c.oils.acq.fund_source %>
+
+<form action='${c.oils.acq.prefix}/fund_source/create_credit' method='POST'>
+    <input type='hidden' name='${c.oils.acq.fund_source_id_.cgi_name}' value='${source.id()}'/>
+    <table class='oils-admin-table'>
+        <tbody>
+            <tr>
+                <td class='oils-admin-label'>${_('Funding Source')}</td>
+                <% 
+                    label = _('%(name)s (%(owner)s)') % {'name':source.name(), 'owner':source.owner().shortname()}
+                %>
+                <td>${label}</td>
+            </tr>
+            <tr>
+                <td class='oils-admin-label'>${_('Amount')}</td>
+                <td><input type='text' size='8' name='${c.oils.acq.fund_source_credit_amount_.cgi_name}'/></td>
+            </tr>
+            <tr>
+                <td class='oils-admin-label'>${_('Note')}</td>
+                <td> 
+                    <textarea name='${c.oils.acq.fund_source_credit_note_.cgi_name}'> </textarea>
+                </td>
+            </tr>
+            <tr>
+                <td colspan='2'>
+                    <input type='submit' value='${_("Create Funding Source Credit")}'/>
+                </td>
+            </tr>
+        </tbody>
+    </table>
+</form>
+</%def>

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html	2008-02-12 18:02:42 UTC (rev 8733)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html	2008-02-12 18:04:08 UTC (rev 8734)
@@ -3,13 +3,17 @@
 <%namespace file='../../common/widgets.html' name='widget'/>
 <%def name="page_title()">${_('View Fund')}</%def>
 <%def name="block_content()">
+
+<div id='oils-acq-list-header' class='container'>
+    <div id='oils-acq-list-header-label'>${c.oils.acq.fund.name()}</div>
+    <div id='oils-acq-list-header-create'>
+        <a href='${c.oils.acq.prefix}/fund/allocate?${c.oils.acq.fund_id_.cgi_name}=${c.oils.acq.fund.id()}'>${_('Allocate Money')}</a>
+    </div>
+</div>
+
 <table class='oils-admin-table'>
     <tbody>
         <tr>
-            <td class='oils-admin-label'>${_('Name')}</td>
-            <td>${c.oils.acq.fund.name()}</td>
-        </tr>
-        <tr>
             <td class='oils-admin-label'>${_('Owner')}</td>
             <td>${c.oils.acq.fund.org().name()}</td> 
         </tr>
@@ -47,7 +51,4 @@
         </tr>
     </tbody>
 </table>
-<div>
-    <a href='${c.oils.acq.prefix}/fund/allocate?${c.oils.acq.fund_id_.cgi_name}=${c.oils.acq.fund.id()}'>${_('Allocate Money')}</a>
-</div>
 </%def>

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-12 18:02:42 UTC (rev 8733)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html	2008-02-12 18:04:08 UTC (rev 8734)
@@ -3,31 +3,37 @@
 <%namespace file='../../common/widgets.html' name='widget'/>
 <%def name="page_title()">${_('View Funding Source')}</%def>
 <%def name="block_content()">
+
+<% source = c.oils.acq.fund_source %>
+
+<div id='oils-acq-list-header' class='container'>
+    <div id='oils-acq-list-header-label'>${source.name()}</div>
+    <div id='oils-acq-list-header-create'>
+        <a href='${c.oils.acq.prefix}/fund_source/create_credit?${c.oils.acq.fund_source_id_.cgi_name}=${source.id()}'>${_('Add Credit')}</a>
+    </div>
+</div>
+
 <table class='oils-admin-table'>
     <tbody>
         <tr>
-            <td class='oils-admin-label'>${_('Funding Source Name')}</td>
-            <td>${c.oils.acq.fund_source.name()}</td>
-        </tr>
-        <tr>
             <td class='oils-admin-label'>${_('Funding Source Owner')}</td>
-            <td>${c.oils.acq.fund_source.owner().name()}</td> 
+            <td>${source.owner().name()}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Funding Source Currency Type')}</td>
-            <td>${c.oils.acq.fund_source.currency_type()}</td> 
+            <td>${source.currency_type()}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Funding Source Credit Total')}</td>
-            <td>${c.oils.acq.fund_source.summary()['credit_total']}</td> 
+            <td>${source.summary()['credit_total']}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Funding Source Allocation Total')}</td>
-            <td>${c.oils.acq.fund_source.summary()['allocation_total']}</td> 
+            <td>${source.summary()['allocation_total']}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Funding Source Balance')}</td>
-            <td>${c.oils.acq.fund_source.summary()['balance']}</td> 
+            <td>${source.summary()['balance']}</td> 
         </tr>
     </tbody>
 </table>



More information about the open-ils-commits mailing list