From b24049948e5f29cf3bdafcc5d42fc1d1edfc799c Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 30 Jan 2008 18:14:37 +0000 Subject: [PATCH] updated to suit terminonolgy change on fund objects git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8541 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../oilsweb/oilsweb/controllers/acq/__init__.py | 9 +++-- .../web/oilsweb/oilsweb/controllers/acq/fund.py | 3 +- .../oilsweb/oilsweb/controllers/acq/fund_source.py | 44 ++++++++++++++++++++++ Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py | 27 +++++++++++++ .../{create_fund.html => create_fund_source.html} | 8 ++-- .../{list_funds.html => list_fund_sources.html} | 8 ++-- .../oils/default/acq/financial/navigate.html | 4 +- .../{view_fund.html => view_fund_source.html} | 8 ++-- .../templates/oils/default/acq/navigate.html | 3 ++ 9 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py rename Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/{create_fund.html => create_fund_source.html} (82%) rename Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/{list_funds.html => list_fund_sources.html} (66%) rename Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/{view_fund.html => view_fund_source.html} (70%) diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py index 03c23a171e..9636974abb 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py @@ -32,10 +32,11 @@ class AcqContext(SubContext): self.currency_types = ContextItem() self.fund = ContextItem() - self.fund_list = ContextItem() - self.fund_name = ContextItem(cgi_name='acq.fn') - self.fund_currency_type = ContextItem(cgi_name='acq.fc') - self.fund_owner = ContextItem(cgi_name='acq.fo') + self.fund_source = ContextItem() + self.fund_source_list = ContextItem() + self.fund_source_name = ContextItem(cgi_name='acq.fn') + self.fund_source_currency_type = ContextItem(cgi_name='acq.fc') + self.fund_source_owner = ContextItem(cgi_name='acq.fo') # ------------------------------------------------------------- # utility functions diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py index 63a031e6b3..eb5a5facb6 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -5,6 +5,8 @@ import oilsweb.lib.acq.fund import osrf.net_obj import oils.org +# XXX update to match new fund layout + class FundController(BaseController): def view(self, **kwargs): @@ -40,4 +42,3 @@ class FundController(BaseController): r.ctx.acq.currency_types = fund_mgr.fetch_currency_types() r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree() return r.render('acq/financial/create_fund.html') - diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py new file mode 100644 index 0000000000..9400986faf --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py @@ -0,0 +1,44 @@ +from oilsweb.lib.base import * +import pylons +from oilsweb.lib.request import RequestMgr +import oilsweb.lib.acq.fund +import osrf.net_obj +import oils.org + + +class FundSourceController(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) + source = fund_mgr.retrieve_fund_source(kwargs.get('id')) + source.owner(oils.org.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() + fund_mgr = oilsweb.lib.acq.fund.FundMgr(r) + r.ctx.acq.fund_source_list = fund_mgr.retrieve_org_fund_sources() + for f in r.ctx.acq.fund_source_list: + f.owner(oils.org.OrgUtil.get_org_unit(f.owner())) + return r.render('acq/financial/list_fund_sources.html') + + + def create(self): + r = RequestMgr() + fund_mgr = oilsweb.lib.acq.fund.FundMgr(r) + + if r.ctx.acq.fund_source_name: + source = osrf.net_obj.NetworkObject.acqfs() + source.name(r.ctx.acq.fund_source_name) + source.owner(r.ctx.acq.fund_source_owner) + source.currency_type(r.ctx.acq.fund_source_currency_type) + 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() + r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree() + return r.render('acq/financial/create_fund_source.html') + diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py index 21063654a1..a52e25eefd 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py @@ -14,6 +14,7 @@ class FundMgr(object): oils.event.Event.parse_and_raise(types) return types + ''' XXX update to look like a fund def retrieve(self, fund_id): fund = self.ses.request( 'open-ils.acq.fund.retrieve', @@ -37,5 +38,31 @@ class FundMgr(object): self.request_mgr.ctx.core.authtoken, fund).recv().content() oils.event.Event.parse_and_raise(fund_id) return fund_id + ''' + def retrieve_fund_source(self, source_id): + source = self.ses.request( + 'open-ils.acq.funding_source.retrieve', + self.request_mgr.ctx.core.authtoken, source_id).recv().content() + oils.event.Event.parse_and_raise(source) + return source + + def retrieve_org_fund_sources(self): + sources = self.ses.request( + 'open-ils.acq.funding_source.org.retrieve', + self.request_mgr.ctx.core.authtoken, + self.request_mgr.ctx.core.workstation.owning_lib(), + {"full_path":1}).recv().content() + oils.event.Event.parse_and_raise(sources) + return sources + + + def create_fund_source(self, source): + source_id = self.ses.request( + 'open-ils.acq.funding_source.create', + self.request_mgr.ctx.core.authtoken, source).recv().content() + oils.event.Event.parse_and_raise(source_id) + return source_id + + diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_source.html similarity index 82% rename from Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html rename to Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_source.html index d45f504720..36f20dae56 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_source.html @@ -4,26 +4,26 @@ <%def name="page_title()">${_('Evergreen Create Fund')} <%def name="block_content()"> -
+ - % for fund in c.oils.acq.fund_list: + % for source in c.oils.acq.fund_source_list: - - - + + + %endfor diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/navigate.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/navigate.html index cf932a86b4..a66b86b59c 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/navigate.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/navigate.html @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html similarity index 70% rename from Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html rename to Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html index 4ee52c8056..1266e63956 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html @@ -4,20 +4,20 @@ <%def name="page_title()">${_('Evergreen Create Fund')} <%def name="block_content()"> - +
${_('Fund Name')} - +
${_('Fund Onwer')} - ${widget.org_select(c.oils.acq.fund_owner_.cgi_name)} + ${widget.org_select(c.oils.acq.fund_source_owner_.cgi_name)} * ADD PERM FILTER HERE *
${_('Fund Currency Type')} - % for type in c.oils.acq.currency_types: % endfor diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html similarity index 66% rename from Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html rename to Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html index b29e75c71b..cc1df2f0ff 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html @@ -13,11 +13,11 @@
${fund.name()}${fund.owner().name()}${fund.currency_type()}${source.name()}${source.owner().name()}${source.currency_type()}
- + - + - +
${_('Fund Name')}${c.oils.acq.fund.name()}${c.oils.acq.fund_source.name()}
${_('Fund Onwer')}${c.oils.acq.fund.owner().name()}${c.oils.acq.fund_source.owner().name()}
${_('Fund Currency Type')}${c.oils.acq.fund.currency_type()}${c.oils.acq.fund_source.currency_type()}
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 76068dad23..518dc7b0b4 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,10 @@ % endif % if c.oils.core.page.startswith('acq/financial'):
-- 2.11.0