From 73b463a6743e156927a567e32a9124c732e99794 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 12 Feb 2008 18:04:08 +0000 Subject: [PATCH] added ability to create a funding_source_credit. some minor code cleanup git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8734 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../oilsweb/oilsweb/controllers/acq/__init__.py | 3 ++ .../web/oilsweb/oilsweb/controllers/acq/fund.py | 34 +++++++++------- .../oilsweb/oilsweb/controllers/acq/fund_source.py | 46 +++++++++++++++++----- .../oilsweb/oilsweb/controllers/acq/picklist.py | 25 +++++++----- .../oils/default/acq/financial/create_fund.html | 2 +- .../financial/create_funding_source_credit.html | 41 +++++++++++++++++++ .../oils/default/acq/financial/view_fund.html | 15 +++---- .../default/acq/financial/view_fund_source.html | 24 ++++++----- 8 files changed, 139 insertions(+), 51 deletions(-) create mode 100644 Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_funding_source_credit.html diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py index 4018f0b10b..f3aec130a1 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py @@ -47,10 +47,13 @@ class AcqContext(SubContext): 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() diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py index 5427e708b6..f007d3eb55 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -2,8 +2,12 @@ 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, 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): @@ -11,16 +15,16 @@ class FundController(BaseController): ''' 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 @@ class FundController(BaseController): 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 @@ class FundController(BaseController): 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 @@ class FundController(BaseController): 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 @@ class FundController(BaseController): 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 @@ class FundController(BaseController): 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 @@ class FundController(BaseController): 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) diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py index fddbaa6155..6c2037dd34 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py @@ -3,38 +3,41 @@ import pylons 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 @@ class FundSourceController(BaseController): 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 @@ class FundSourceController(BaseController): 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') + diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py index 9e880eaa11..bc80055537 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py @@ -3,8 +3,11 @@ from oilsweb.lib.request import RequestMgr 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): @@ -24,10 +27,10 @@ class PicklistController(BaseController): 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 @@ class PicklistController(BaseController): 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 @@ class PicklistController(BaseController): 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) 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.html index 065fe6eef3..d6d0a22d1f 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.html @@ -36,7 +36,7 @@ ${_('Fund Year')} - + diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_funding_source_credit.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_funding_source_credit.html new file mode 100644 index 0000000000..7a7549b36d --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_funding_source_credit.html @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +<%inherit file='../base.html'/> +<%namespace file='../../common/widgets.html' name='widget'/> +<%def name="page_title()">${_('Create Funding Source Credit')} +<%def name="block_content()"> + +<% source = c.oils.acq.fund_source %> + +
+ + + + + + <% + label = _('%(name)s (%(owner)s)') % {'name':source.name(), 'owner':source.owner().shortname()} + %> + + + + + + + + + + + + + + +
${_('Funding Source')}${label}
${_('Amount')}
${_('Note')} + +
+ +
+
+ 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.html index 3e39a0445a..96d2085c7e 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.html @@ -3,13 +3,17 @@ <%namespace file='../../common/widgets.html' name='widget'/> <%def name="page_title()">${_('View Fund')} <%def name="block_content()"> + +
+
${c.oils.acq.fund.name()}
+ +
+ - - - - @@ -47,7 +51,4 @@
${_('Name')}${c.oils.acq.fund.name()}
${_('Owner')} ${c.oils.acq.fund.org().name()}
-
- ${_('Allocate Money')} -
diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html index 29e3b54683..d2575fb847 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html @@ -3,31 +3,37 @@ <%namespace file='../../common/widgets.html' name='widget'/> <%def name="page_title()">${_('View Funding Source')} <%def name="block_content()"> + +<% source = c.oils.acq.fund_source %> + +
+
${source.name()}
+ +
+ - - - - - + - + - + - + - +
${_('Funding Source Name')}${c.oils.acq.fund_source.name()}
${_('Funding Source Owner')}${c.oils.acq.fund_source.owner().name()}${source.owner().name()}
${_('Funding Source Currency Type')}${c.oils.acq.fund_source.currency_type()}${source.currency_type()}
${_('Funding Source Credit Total')}${c.oils.acq.fund_source.summary()['credit_total']}${source.summary()['credit_total']}
${_('Funding Source Allocation Total')}${c.oils.acq.fund_source.summary()['allocation_total']}${source.summary()['allocation_total']}
${_('Funding Source Balance')}${c.oils.acq.fund_source.summary()['balance']}${source.summary()['balance']}
-- 2.11.0