self.picklist_entry = ContextItem() # picklist_entry object
self.currency_types = ContextItem()
+ self.fund = 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')
class FundController(BaseController):
def view(self, **kwargs):
- return 'view %s' % kwargs['id']
+ 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.owner(oils.org.OrgUtil.get_org_unit(fund.owner())) # flesh the owner
+ r.ctx.acq.fund = fund
+ return r.render('acq/financial/view_fund.html')
+
+ def list(self):
+ pass
def create(self):
r = RequestMgr()
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)
+ 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()
oils.event.Event.parse_and_raise(types)
return types
+ def retrieve(self, fund_id):
+ status = self.ses.request(
+ 'open-ils.acq.fund.retrieve',
+ self.request_mgr.ctx.core.authtoken, fund_id).recv().content()
+ oils.event.Event.parse_and_raise(status)
+ return status
+
def create_fund(self, fund):
fund_id = self.ses.request(
'open-ils.acq.fund.create',
--- /dev/null
+# -*- coding: utf-8 -*-
+<%inherit file='../base.html'/>
+<%namespace file='../../common/widgets.html' name='widget'/>
+<%def name="page_title()">${_('Evergreen Create Fund')}</%def>
+<%def name="block_content()">
+
+<form action='${c.oils.acq.prefix}/fund/create' method='POST'>
+ <table class='oils-admin-table'>
+ <tbody>
+ <tr>
+ <td class='oils-admin-label'>${_('Fund Name')}</td>
+ <td>${c.oils.acq.fund.name()}</td>
+ </tr>
+ <tr>
+ <td class='oils-admin-label'>${_('Fund Onwer')}</td>
+ <td>${c.oils.acq.fund.owner().name()}</td>
+ </tr>
+ <tr>
+ <td class='oils-admin-label'>${_('Fund Currency Type')}</td>
+ <td>${c.oils.acq.fund.currency_type()}</td>
+ </tr>
+ </tbody>
+ </table>
+</form>
+</%def>
Define some common widgets
-->
-<%def name='org_draw_node(node, indent=0)'>
- <option value='${node.id()}'>
+<%def name='org_draw_node(node, indent=0, selected=None)'>
+ <option value='${node.id()}'
+ % if selected == node.id():
+ selected='selected'
+ %endif
+ >
% for i in range(indent):
  
% endfor
</%def>
-<%def name='org_select(select_name, tree=None)'>
+<%def name='org_select(select_name, tree=None, selected=None)'>
<!-- Draws a select dropdown of the org tree provided
with indentation based on org depth -->
<%
tree = c.oils.core.org_tree
%>
<select name='${select_name}'>
- ${org_draw_node(tree, 0)}
+ ${org_draw_node(tree, 0, selected)}
</select>
</%def>