From 1c339dcfa81e9f09119e5303507daa7e2df007f0 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 6 Feb 2008 21:30:39 +0000 Subject: [PATCH] added fund_allocation creation, added fund summary display git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8675 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../oilsweb/oilsweb/controllers/acq/__init__.py | 12 ++++++ .../web/oilsweb/oilsweb/controllers/acq/fund.py | 44 ++++++++++++++++++++-- Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py | 14 +++++-- .../oilsweb/public/oils/media/css/skin/default.css | 3 +- 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py index dd9100dd82..c03ccf03c9 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py @@ -33,10 +33,12 @@ class AcqContext(SubContext): self.currency_types = ContextItem() self.fund = ContextItem() + self.fund_id = ContextItem(cgi_name='acq.fi') self.fund_list = ContextItem() self.fund_name = ContextItem(cgi_name='acq.fn') self.fund_year = ContextItem(cgi_name='acq.fc') self.fund_org = ContextItem(cgi_name='acq.fo') + self.fund_summary = ContextItem() self.fund_source = ContextItem() self.fund_source_list = ContextItem() @@ -44,6 +46,16 @@ class AcqContext(SubContext): self.fund_source_currency_type = ContextItem(cgi_name='acq.fc') self.fund_source_owner = ContextItem(cgi_name='acq.fo') + + self.fund_allocation = ContextItem() + self.fund_allocation_list = ContextItem() + self.fund_allocation_source= ContextItem(cgi_name='acq.fas') + self.fund_allocation_fund = ContextItem(cgi_name='acq.faf') + self.fund_allocation_amount = ContextItem(cgi_name='acq.faa') + self.fund_allocation_percent = ContextItem(cgi_name='acq.fap') + self.fund_allocation_note = ContextItem(cgi_name='acq.fan') + + # ------------------------------------------------------------- # utility functions self.find_entry_attr = ContextItem( diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py index ce378a66f9..3fffde96d2 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -2,18 +2,31 @@ from oilsweb.lib.base import * import pylons from oilsweb.lib.request import RequestMgr import oilsweb.lib.acq.fund, oilsweb.lib.user -import osrf.net_obj -import oils.org +import osrf.net_obj, osrf.ses +import oils.org, oils.const, oils.event class FundController(BaseController): def view(self, **kwargs): r = RequestMgr() r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree() - fund_mgr = oilsweb.lib.acq.fund.FundMgr(r) - fund = fund_mgr.retrieve(kwargs.get('id')) + 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 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): @@ -45,4 +58,27 @@ class FundController(BaseController): return r.render('acq/financial/create_fund.html') + def allocate(self): + r = RequestMgr() + fund_mgr = oilsweb.lib.acq.fund.FundMgr(r) + + 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 + r.ctx.acq.fund = fund + r.ctx.acq.fund_source_list = fund_mgr.retrieve_org_fund_sources('MANAGE_FUNDING_SOURCE') + return r.render('acq/financial/create_fund_allocation.html') + + diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py index 745c2099bf..c6e2e5733a 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py @@ -21,10 +21,10 @@ class FundMgr(object): oils.event.Event.parse_and_raise(fund) return fund - def retrieve_org_funds(self): + def retrieve_org_funds(self, limit_perm=None): funds = self.ses.request( 'open-ils.acq.fund.org.retrieve', - self.request_mgr.ctx.core.authtoken).recv().content() + self.request_mgr.ctx.core.authtoken, None, limit_perm).recv().content() oils.event.Event.parse_and_raise(funds) return funds @@ -43,10 +43,10 @@ class FundMgr(object): oils.event.Event.parse_and_raise(source) return source - def retrieve_org_fund_sources(self): + def retrieve_org_fund_sources(self, limit_perm=None): sources = self.ses.request( 'open-ils.acq.funding_source.org.retrieve', - self.request_mgr.ctx.core.authtoken).recv().content() + self.request_mgr.ctx.core.authtoken, None, limit_perm).recv().content() oils.event.Event.parse_and_raise(sources) return sources @@ -58,4 +58,10 @@ class FundMgr(object): oils.event.Event.parse_and_raise(source_id) return source_id + def create_allocation(self, alloc): + alloc_id = self.ses.request( + 'open-ils.acq.fund_allocation.create', + self.request_mgr.ctx.core.authtoken, alloc).recv().content() + oils.event.Event.parse_and_raise(alloc_id) + return alloc_id diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css index 6002bf839b..518a6fba31 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css @@ -28,7 +28,8 @@ body { margin-top: 0px; padding-top: 0px;} /* general purpose form table */ .oils-admin-table { width: 100%; } .oils-admin-table td { padding: 4px; } -.oils-admin-label { width: 20%; } +.oils-admin-table textarea { width: 400px; height: 40px; overflow:auto;} +.oils-admin-label { width: auto; } .label { margin: 1px; } -- 2.11.0