Ugly text dump of registry objects and exposed CSEditor methods
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 21 Dec 2007 20:21:19 +0000 (20:21 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 21 Dec 2007 20:21:19 +0000 (20:21 +0000)
Adds new route at http://hostname:5000/acq/admin

git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8273 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/config/routing.py
Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py [new file with mode: 0644]
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html [new file with mode: 0644]

index bc78800..853cbe5 100644 (file)
@@ -19,7 +19,9 @@ def make_map():
     # CUSTOM ROUTES HERE
 
     map.connect('oils/:controller/:action')
-    #map.connect(':controller/:action/:id')
+    map.connect('acq_admin', 'oils/admin', controller='acq_admin')
+    map.connect('acq_admin_object', 'oils/admin/:object', controller='acq_admin')
+    map.connect('acq_admin_direct', 'oils/admin/direct/:object/:id', controller='acq_admin')
     map.connect('*url', controller='template', action='view')
 
     return map
diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py
new file mode 100644 (file)
index 0000000..13add6c
--- /dev/null
@@ -0,0 +1,41 @@
+import logging
+
+from oilsweb.lib.base import *
+import pylons, os
+import oilsweb.lib.context
+import oilsweb.lib.util
+import oilsweb.lib.acq.search
+from oilsweb.lib.context import Context, SubContext, ContextItem
+
+import oils.utils.csedit
+import osrf.log
+import osrf.system
+from oils.utils.idl import oilsParseIDL
+from oils.utils.csedit import oilsLoadCSEditor
+
+def oilsConnect(config, configContext):
+       """Connects to the opensrf network,  parses the IDL file, and loads the CSEditor"""
+       osrf.system.connect(config, configContext)
+       oilsParseIDL()
+       oilsLoadCSEditor()
+
+log = logging.getLogger(__name__)
+
+class AcqAdminController(BaseController):
+
+    def index(self):
+        """
+        List the acquisition objects that we're allowed to administer
+        """
+
+        import pprint
+
+        # Parse IDL and render as links for viewing the objects, perhaps?
+        c.oils = oilsweb.lib.context.Context.init(request)
+        c.request = request
+        oilsConnect('/openils/conf/opensrf_core.xml', 'config.opensrf')
+        c.idl = oils.utils.idl.oilsGetIDLParser()
+        c.csedit = oils.utils.csedit.CSEditor()
+        c.registry = osrf.net_obj.OBJECT_REGISTRY
+        return render('oils/%s/acq/admin.html' % c.oils.core.skin)
+
diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html
new file mode 100644 (file)
index 0000000..dc243e9
--- /dev/null
@@ -0,0 +1,57 @@
+<%inherit file='../base.html'/>
+<%def name="block_title()">${_('Evergreen Acquisitions Administration ')}</%def>
+<%def name="block_content()">
+<h1>${_('Evergreen Acquisitions Administration ')}</h1>
+<pre>
+
+    Check for a session key in GET dictionary object:
+    % if c.request.GET.has_key('ses'):
+        SESSION = ${c.request.GET['ses']}
+    % else:
+        NO SESSION
+    % endif
+
+    Try some sample method calls - no session appears to be required,
+    possibly because I'm performing the connect in acq_admin.py
+    <%
+    csd = c.csedit.retrieve_acq_exchange_rate(1)
+    eur = c.csedit.retrieve_acq_exchange_rate(2)
+    %>
+    csd = c.csedit.retrieve_acq_exchange_rate(1)
+    csd.to_currency()
+    Result = ${csd.to_currency()}
+
+    eur = c.csedit.retrieve_acq_exchange_rate(2)
+    eur.to_currency()
+    Result = ${eur.to_currency()}
+
+    Iterate through the acq schema registry objects, dumping interesting info
+    that we should be able to wrap into a series of links and forms for
+    administrative purposes.
+
+    Registry:
+    % for key in sorted(c.registry):
+       % if c.idl.IDLObject.has_key(key) and str(c.idl.IDLObject[key]['tablename'])[0:4] == 'acq.':
+            registry hint: ${key}
+            tablename    : ${c.idl.IDLObject[key]['tablename']}
+            controller   : ${c.idl.IDLObject[key]['controller']}
+            virtual      : ${c.idl.IDLObject[key]['virtual']}
+            fieldmapper  : ${c.idl.IDLObject[key]['fieldmapper']}
+            KEYS
+            %for regkey in c.registry[key].keys:
+                ${regkey}
+            % endfor
+
+        % endif
+    % endfor 
+
+    List the callable methods in the CSEditor object, more for interest than anything else:
+
+    CSEditor object:
+    % for att in [att for att in dir(c.csedit) if callable(getattr(c.csedit, att)) and att[0:2] != '__']:
+        ${att}
+    % endfor
+
+
+</pre>
+</%def>