From 6b00e6a8fa6e95742b30bf72f560740fbcb81f4f Mon Sep 17 00:00:00 2001 From: dbs Date: Fri, 21 Dec 2007 20:21:19 +0000 Subject: [PATCH] Ugly text dump of registry objects and exposed CSEditor methods 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 | 4 +- .../web/oilsweb/oilsweb/controllers/acq_admin.py | 41 ++++++++++++++++ .../oilsweb/templates/oils/default/acq/admin.html | 57 ++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py create mode 100644 Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html diff --git a/Open-ILS/web/oilsweb/oilsweb/config/routing.py b/Open-ILS/web/oilsweb/oilsweb/config/routing.py index bc78800486..853cbe5773 100644 --- a/Open-ILS/web/oilsweb/oilsweb/config/routing.py +++ b/Open-ILS/web/oilsweb/oilsweb/config/routing.py @@ -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 index 0000000000..13add6cd16 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq_admin.py @@ -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 index 0000000000..dc243e9772 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/admin.html @@ -0,0 +1,57 @@ +<%inherit file='../base.html'/> +<%def name="block_title()">${_('Evergreen Acquisitions Administration ')} +<%def name="block_content()"> +

${_('Evergreen Acquisitions Administration ')}

+
+
+    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
+
+
+
+ -- 2.11.0