From 2d8a65c87072a34d510c7fd15dae5baaf7d808ed Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 5 Feb 2008 16:15:45 +0000 Subject: [PATCH] moved some work org logic into the new user class. started basic fund management git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8639 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../web/oilsweb/oilsweb/controllers/acq/__init__.py | 6 ++++++ Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py | 20 ++++++++++++-------- .../oilsweb/oilsweb/controllers/acq/fund_source.py | 1 - Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py | 4 ++-- Open-ILS/web/oilsweb/oilsweb/lib/user.py | 13 +++++++++++++ .../oils/default/acq/financial/navigate.html | 3 +++ 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py index 9636974abb..dd9100dd82 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py @@ -31,7 +31,13 @@ class AcqContext(SubContext): self.picklist_entry = ContextItem() # picklist_entry object self.currency_types = ContextItem() + self.fund = ContextItem() + 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_source = ContextItem() self.fund_source_list = ContextItem() self.fund_source_name = ContextItem(cgi_name='acq.fn') diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py index eb5a5facb6..2c4aebb855 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -1,12 +1,10 @@ from oilsweb.lib.base import * import pylons from oilsweb.lib.request import RequestMgr -import oilsweb.lib.acq.fund +import oilsweb.lib.acq.fund, oilsweb.lib.user import osrf.net_obj import oils.org -# XXX update to match new fund layout - class FundController(BaseController): def view(self, **kwargs): @@ -32,13 +30,19 @@ class FundController(BaseController): fund_mgr = oilsweb.lib.acq.fund.FundMgr(r) if r.ctx.acq.fund_name: - fund = osrf.net_obj.NetworkObject.acqfund() + fund = osrf.net_obj.NetworkObject.acqf() fund.name(r.ctx.acq.fund_name) - fund.owner(r.ctx.acq.fund_owner) - fund.currency_type(r.ctx.acq.fund_currency_type) + fund.org(r.ctx.acq.fund_org) + fund.year(r.ctx.acq.fund_year) fund_id = fund_mgr.create_fund(fund) return redirect_to(controller='acq/fund', action='view', id=fund_id) - r.ctx.acq.currency_types = fund_mgr.fetch_currency_types() - r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree() + usermgr = oilsweb.lib.user.User(r.ctx.core) + tree = usermgr.highest_work_perm_tree('CREATE_FUND') + + if tree is None: + return _("Insufficient Permissions") # XXX Return a perm failure template + 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 index b19d058740..9cea205f28 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py @@ -46,7 +46,6 @@ class FundSourceController(BaseController): if len(perm_orgs) == 0: return _("Insufficient Permissions") # XXX Return a perm failure template - r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree() r.ctx.core.perm_tree['CREATE_FUNDING_SOURCE'] = oils.org.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() diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py index e3548dfc68..f35df273de 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py @@ -14,7 +14,6 @@ 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', @@ -22,6 +21,7 @@ class FundMgr(object): oils.event.Event.parse_and_raise(fund) return fund + ''' XXX update to look like a fund def retrieve_org_funds(self): funds = self.ses.request( 'open-ils.acq.fund.org.retrieve', @@ -32,13 +32,13 @@ class FundMgr(object): return funds + ''' def create_fund(self, fund): fund_id = self.ses.request( 'open-ils.acq.fund.create', 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): diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/user.py b/Open-ILS/web/oilsweb/oilsweb/lib/user.py index d0f47c1147..2be4fea56a 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/user.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/user.py @@ -59,5 +59,18 @@ class User(object): oils.event.Event.parse_and_raise(work_orgs) return work_orgs + def highest_work_perm_set(self, perm): + perm_orgs = osrf.ses.ClientSession.atomic_request( + 'open-ils.actor', + 'open-ils.actor.user.work_perm.highest_org_set', self.ctx.authtoken, perm); + self.ctx.high_perm_orgs[perm] = perm_orgs + return perm_orgs + + def highest_work_perm_tree(self, perm): + perm_orgs = self.highest_work_perm_set(perm) + if len(perm_orgs) == 0: + return None + self.ctx.perm_tree[perm] = oils.org.OrgUtil.get_union_tree(perm_orgs) + return self.ctx.perm_tree[perm] 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 aee41d99d8..f67681a501 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,5 +1,8 @@ # -*- coding: utf-8 -*-
+ ${_('New Fund')} +
+
${_('Fund Sources')}
-- 2.11.0