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

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Feb 7 11:37:45 EST 2008


Author: erickson
Date: 2008-02-07 11:09:08 -0500 (Thu, 07 Feb 2008)
New Revision: 8684

Modified:
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html
Log:
moving away from oilsweb.lib.acq.fund, generally unnecessary abstraction layer.  pointing to fund list by default

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-07 15:49:59 UTC (rev 8683)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py	2008-02-07 16:09:08 UTC (rev 8684)
@@ -7,47 +7,54 @@
 
 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
+        return fund
+
+
     def view(self, **kwargs):
         r = RequestMgr()
         r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree()
         fund_id = kwargs['id']
-
         ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
-        fund_req = ses.request('open-ils.acq.fund.retrieve', r.ctx.core.authtoken, fund_id)
-        fund_summary_req = ses.request('open-ils.acq.fund.summary.retrieve', r.ctx.core.authtoken, fund_id)
 
         # grab the fund object
-        fund = fund_req.recv().content()
-        oils.event.Event.parse_and_raise(fund)
-        fund.org(oils.org.OrgUtil.get_org_unit(fund.org())) # flesh the org
+        fund = self._retrieve_fund(r, ses, fund_id)
         r.ctx.acq.fund = fund
-
-        # grab the fund summary
-        fund_summary = fund_summary_req.recv().content()
-        oils.event.Event.parse_and_raise(fund_summary)
-        r.ctx.acq.fund_summary = fund_summary
-
         return r.render('acq/financial/view_fund.html')
 
     def list(self):
         r = RequestMgr()
-        fund_mgr = oilsweb.lib.acq.fund.FundMgr(r)
-        r.ctx.acq.fund_list = fund_mgr.retrieve_org_funds()
-        for f in r.ctx.acq.fund_list:
+        ses = osrf.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)
+        for f in funds:
             f.org(oils.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()
-        fund_mgr = oilsweb.lib.acq.fund.FundMgr(r)
+        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
 
-        if r.ctx.acq.fund_name:
+        if r.ctx.acq.fund_name: # create then display the fund
+
             fund = osrf.net_obj.NetworkObject.acqf()
             fund.name(r.ctx.acq.fund_name)
             fund.org(r.ctx.acq.fund_org)
             fund.year(r.ctx.acq.fund_year)
-            fund_id = fund_mgr.create_fund(fund)
+
+            fund_id = ses.request('open-ils.acq.fund.create', 
+                r.ctx.core.authtoken, fund).recv().content()
+            oils.event.Event.parse_and_raise(fund_id)
+
             return redirect_to(controller='acq/fund', action='view', id=fund_id)
 
         usermgr = oilsweb.lib.user.User(r.ctx.core)
@@ -60,25 +67,40 @@
 
     def allocate(self):
         r = RequestMgr()
-        fund_mgr = oilsweb.lib.acq.fund.FundMgr(r)
+        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
 
         if r.ctx.acq.fund_allocation_source:
-            alloc = osrf.net_obj.NetworkObject.acqfa()
-            alloc.funding_source(r.ctx.acq.fund_allocation_source)
-            alloc.fund(r.ctx.acq.fund_allocation_fund)
-            if r.ctx.acq.fund_allocation_amount:
-                alloc.amount(r.ctx.acq.fund_allocation_amount)
-            else:
-                alloc.percent(r.ctx.acq.fund_allocation_percent)
-            alloc.note(r.ctx.acq.fund_allocation_note)
-            fund_mgr.create_allocation(alloc)
-            return redirect_to(controller='acq/fund', action='view', id=r.ctx.acq.fund_allocation_fund)
+            return self._allocate(r, ses)
 
-        fund = fund_mgr.retrieve(r.ctx.acq.fund_id)
-        fund.org(oils.org.OrgUtil.get_org_unit(fund.org())) # flesh the org
+        fund = self._retrieve_fund(r, ses, fund_id)
+
+        source_list = self.ses.request(
+            'open-ils.acq.funding_source.org.retrieve', 
+            self.request_mgr.ctx.core.authtoken, None, 'MANAGE_FUNDING_SOURCE').recv().content()
+        oils.event.Event.parse_and_raise(sources)
+
         r.ctx.acq.fund = fund
-        r.ctx.acq.fund_source_list = fund_mgr.retrieve_org_fund_sources('MANAGE_FUNDING_SOURCE')
+        r.ctx.acq.fund_source_list = source_list
         return r.render('acq/financial/create_fund_allocation.html')
 
+    def _allocate(self, r, ses):
+        ''' Create a new fund_allocation '''
 
+        alloc = osrf.net_obj.NetworkObject.acqfa()
+        alloc.funding_source(r.ctx.acq.fund_allocation_source)
+        alloc.fund(r.ctx.acq.fund_allocation_fund)
 
+        if r.ctx.acq.fund_allocation_amount:
+            alloc.amount(r.ctx.acq.fund_allocation_amount)
+        else:
+            alloc.percent(r.ctx.acq.fund_allocation_percent)
+        alloc.note(r.ctx.acq.fund_allocation_note)
+
+        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)
+
+        return redirect_to(controller='acq/fund', action='view', id=r.ctx.acq.fund_allocation_fund)
+
+
+

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html	2008-02-07 15:49:59 UTC (rev 8683)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html	2008-02-07 16:09:08 UTC (rev 8684)
@@ -11,7 +11,7 @@
     </div>
 % endif
 <div class='oils-base-navigate-item'>
-    <a href='${c.oils.core.prefix}/acq/fund_source/list'>${_('Funds')}</a>
+    <a href='${c.oils.core.prefix}/acq/fund/list'>${_('Funds')}</a>
     <!--
     <a href='${c.oils.core.prefix}/acq/fund/list'>${_('Funds')}</a>
     -->



More information about the open-ils-commits mailing list