From efd165d438126489994d8ff83ebe7eb1915537fb Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 22 Jan 2008 17:00:04 +0000 Subject: [PATCH] added basic fund create interface, much more to come on that added a common template directory, currently has a widgets file for common widgets implemented an org-tree selector widget git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8458 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../oilsweb/oilsweb/controllers/acq/__init__.py | 10 +++--- .../web/oilsweb/oilsweb/controllers/acq/fund.py | 28 +++++++++++++++ Open-ILS/web/oilsweb/oilsweb/lib/__init__.py | 1 + Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py | 24 +++++++++++++ .../oilsweb/public/oils/media/css/skin/default.css | 5 +++ .../public/oils/media/css/theme/default.css | 3 ++ .../oils/default/acq/financial/create_fund.html | 41 ++++++++++++++++++++++ .../templates/oils/default/common/widgets.html | 31 ++++++++++++++++ 8 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py create mode 100644 Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py create mode 100644 Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html create mode 100644 Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py index 519c1625b5..bcdd7cf806 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py @@ -18,11 +18,6 @@ class AcqContext(SubContext): self.offset = ContextItem(cgi_name='acq.os', default_value=0) self.limit = ContextItem(cgi_name='acq.li', default_value=10) - #self.search_cache_key = ContextItem(cgi_name='acq.sk') - #self.record_id = ContextItem(cgi_name='acq.ri') - #self.record = ContextItem(cgi_name='acq.r') - #self.picklist_item = ContextItem(cgi_name='acq.pi', multi=True) - # ------------------------------------------------------------- # shared objects and data self.prefix = ContextItem() @@ -35,6 +30,11 @@ class AcqContext(SubContext): self.picklist_id_list = ContextItem() # list of picklist objects self.picklist_entry = ContextItem() # picklist_entry object + self.currency_types = 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') + # ------------------------------------------------------------- # 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 new file mode 100644 index 0000000000..cfc92f988a --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -0,0 +1,28 @@ +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 FundController(BaseController): + + def view(self, **kwargs): + return 'view %s' % kwargs['id'] + + def create(self): + r = RequestMgr() + fund_mgr = oilsweb.lib.acq.fund.FundMgr(r) + + if r.ctx.acq.fund_name: + fund = osrf.net_obj.NetworkObject.acqfund() + fund.name(r.ctx.acq.fund_name) + fund.owner(r.ctx.acq.fund_owner) + fund.currency_type(r.ctx.acq.fund_currency_type) + fund_id = fund_mgr.create_fund(fund) + 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() + return r.render('acq/financial/create_fund.html') + diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py b/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py index 7642c07590..aa9d612949 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/__init__.py @@ -26,6 +26,7 @@ class CoreContext(SubContext): self.workstation = ContextItem() # workstation object self.page = ContextItem() # the current page self.use_demo = ContextItem(cgi_name='demo') # use the demo login + self.org_tree = ContextItem() # full org tree def postinit(self): self.prefix = pylons.config['oils_prefix'] diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py new file mode 100644 index 0000000000..215097af08 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py @@ -0,0 +1,24 @@ +import osrf.ses, osrf.net_obj +import oils.const, oils.utils.utils, oils.event + +class FundMgr(object): + ''' Fund utility class ''' + def __init__(self, request_mgr, **kwargs): + self.request_mgr = request_mgr + self.ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ) + + def fetch_currency_types(self): + types = self.ses.request( + 'open-ils.acq.currency_type.all.retrieve', + self.request_mgr.ctx.core.authtoken).recv().content() + oils.event.Event.parse_and_raise(types) + return types + + 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 + + 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 f90dec2907..e62655a65f 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 @@ -26,4 +26,9 @@ body { margin-top: 0px; padding-top: 0px;} .oils-base-sub-navigate-block { text-align: center; padding: 3px; margin-bottom: 10px;} .oils-base-sub-navigate-block span { padding: 3px; } +/* general purpose form table */ +.oils-admin-table { width: 100%; } +.oils-admin-table td { padding: 4px; } +.oils-admin-label { width: 20%; } + .label { margin: 1px; } diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css index 04599afe5f..decdf08db4 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css @@ -19,3 +19,6 @@ body { font-size: 80%; } .oils-base-sub-navigate-block span:hover { background: #6BA160; } .label { font-weight: bold; } + +.oils-admin-table td { border-bottom: 1px solid #5E5E5E; } +.oils-admin-label { font-weight: bold; } 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 new file mode 100644 index 0000000000..d45f504720 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +<%inherit file='../base.html'/> +<%namespace file='../../common/widgets.html' name='widget'/> +<%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)} + * ADD PERM FILTER HERE * +
${_('Fund Currency Type')} + +
+ +
+
+ diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html new file mode 100644 index 0000000000..11f1db4ab3 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html @@ -0,0 +1,31 @@ + + + + +<%def name='org_draw_node(node, indent=0)'> + + <% indent += 1 %> + % for child in node.children(): + ${org_draw_node(child, indent)} + % endfor + + + +<%def name='org_select(select_name, tree=None)'> + + <% + if tree is None: + tree = c.oils.core.org_tree + %> + + -- 2.11.0