From: erickson Date: Thu, 7 Feb 2008 16:09:08 +0000 (+0000) Subject: moving away from oilsweb.lib.acq.fund, generally unnecessary abstraction layer. ... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=54c896a7a3ed5dca7b6decf9a1e4af527d6659ee;p=Evergreen.git moving away from oilsweb.lib.acq.fund, generally unnecessary abstraction layer. pointing to fund list by default git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8684 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py index 3fffde96d2..532b755c00 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -7,47 +7,54 @@ import oils.org, oils.const, oils.event 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: # create then display the fund - if r.ctx.acq.fund_name: 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 @@ class FundController(BaseController): 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) - - fund = fund_mgr.retrieve(r.ctx.acq.fund_id) - fund.org(oils.org.OrgUtil.get_org_unit(fund.org())) # flesh the org + return self._allocate(r, ses) + + 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) + diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html index 5a65f2c191..a708bd5485 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/navigate.html @@ -11,7 +11,7 @@ % endif
- ${_('Funds')} + ${_('Funds')}