added basic fund create interface, much more to come on that
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 22 Jan 2008 17:00:04 +0000 (17:00 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 22 Jan 2008 17:00:04 +0000 (17:00 +0000)
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

Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py
Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py [new file with mode: 0644]
Open-ILS/web/oilsweb/oilsweb/lib/__init__.py
Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py [new file with mode: 0644]
Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css
Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/theme/default.css
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html [new file with mode: 0644]
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html [new file with mode: 0644]

index 519c162..bcdd7cf 100644 (file)
@@ -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 (file)
index 0000000..cfc92f9
--- /dev/null
@@ -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')
+
index 7642c07..aa9d612 100644 (file)
@@ -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 (file)
index 0000000..215097a
--- /dev/null
@@ -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
+
+    
index f90dec2..e62655a 100644 (file)
@@ -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; }
index 04599af..decdf08 100644 (file)
@@ -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 (file)
index 0000000..d45f504
--- /dev/null
@@ -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>
+<%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> 
+                    <input type='text' size='42' name='${c.oils.acq.fund_name_.cgi_name}'/>
+                </td>
+            </tr>
+            <tr>
+                <td class='oils-admin-label'>${_('Fund Onwer')}</td>
+                <td> 
+                    ${widget.org_select(c.oils.acq.fund_owner_.cgi_name)}
+                    <b>* ADD PERM FILTER HERE *</b>
+                </td>
+            </tr>
+            <tr>
+                <td class='oils-admin-label'>${_('Fund Currency Type')}</td>
+                <td> 
+                    <select name='${c.oils.acq.fund_currency_type_.cgi_name}'>
+                        % for type in c.oils.acq.currency_types:
+                            <option value='${type.code()}'>${type.label()}</option>
+                        % endfor
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <td colspan='2'>
+                    <input type='submit' value='${_("Create Fund")}'/>
+                </td>
+            </tr>
+        </tbody>
+    </table>
+</form>
+</%def>
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 (file)
index 0000000..11f1db4
--- /dev/null
@@ -0,0 +1,31 @@
+<!-- vim:set filetype=mako: -->
+
+<!--
+    Define some common widgets 
+-->
+
+<%def name='org_draw_node(node, indent=0)'>
+    <option value='${node.id()}'>
+        % for i in range(indent):
+            &#160;&#160;
+        % endfor
+        ${node.name()} (${node.shortname()})
+    </option> 
+    <% indent += 1 %>
+    % for child in node.children():
+        ${org_draw_node(child, indent)}
+    % endfor
+        
+</%def>
+
+<%def name='org_select(select_name, tree=None)'>
+    <!-- Draws a select dropdown of the org tree provided
+        with indentation based on org depth -->
+    <%
+        if tree is None:
+            tree = c.oils.core.org_tree
+    %>
+    <select name='${select_name}'>
+        ${org_draw_node(tree, 0)}
+    </select>
+</%def>