[open-ils-commits] r8420 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers/acq lib/acq templates/oils/default
templates/oils/default/acq/picklist
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jan 18 15:22:55 EST 2008
Author: erickson
Date: 2008-01-18 14:57:04 -0500 (Fri, 18 Jan 2008)
New Revision: 8420
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/picklist.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/picklist_entry_summary.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/search.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/navigate.html
Log:
added create-picklist-from-search logic
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py 2008-01-18 15:54:51 UTC (rev 8419)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/picklist.py 2008-01-18 19:57:04 UTC (rev 8420)
@@ -36,11 +36,6 @@
def search(self):
- return 'search interface'
-
-
- '''
- def search(self):
r = RequestMgr()
r.ctx.acq.z39_sources = oilsweb.lib.acq.search.fetch_z39_sources(r.ctx)
@@ -52,42 +47,18 @@
keys = sc.keys()
keys.sort()
r.ctx.acq.search_classes_sorted = keys
- log.debug("keys = %s" % unicode(r.ctx.acq.z39_sources))
return r.render('acq/picklist/search.html')
- def pl_builder(self):
+ def do_search(self):
r = RequestMgr()
- # add logic to see where we are fetching bib data from
- # XXX fix
- if r.ctx.acq.search_source:
- c.oils_acq_records, r.ctx.acq.search_cache_key = self._build_z39_search(r.ctx)
+ picklist_id = oilsweb.lib.acq.search.multi_search(
+ r, oilsweb.lib.acq.search.compile_multi_search(r))
+ return redirect_to('%s/picklist/view/%d' % (r.ctx.acq.prefix, int(picklist_id)))
- return r.render('acq/picklist/pl_builder.html')
+ return 'search complete'
-
- def _build_z39_search(self, ctx):
-
- search = {
- 'service' : [],
- 'username' : [],
- 'password' : [],
- 'search' : {}
- }
-
- # collect the sources and credentials
- for src in ctx.acq.search_source:
- search['service'].append(src)
- search['username'].append("") # XXX config values? in-db?
- search['password'].append("") # XXX config values? in-db?
-
- # collect the search classes
- for cls in ctx.acq.search_class:
- if request.params[cls]:
- search['search'][cls] = request.params[cls]
-
- return oilsweb.lib.acq.search.multi_search(ctx, search)
-
+ '''
def rdetails(self):
r = RequestMgr()
rec_id = r.ctx.acq.record_id
@@ -102,12 +73,6 @@
return 'exception -> no record'
- def view_picklist(self):
- r = RequestMgr()
- ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
- picklist = osrf
-
-
def create_picklist(self):
r = RequestMgr()
if not isinstance(r.ctx.acq.picklist_item, list):
@@ -122,10 +87,4 @@
c.oils_acq_records = records # XXX
return r.render('acq/picklist/view.html')
-
- def _find_cached_record(self, results, cache_id):
- for res in results:
- for rec in res['records']:
- if str(rec['cache_id']) == str(cache_id):
- return rec
'''
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/picklist.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/picklist.py 2008-01-18 15:54:51 UTC (rev 8419)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/picklist.py 2008-01-18 19:57:04 UTC (rev 8420)
@@ -1,4 +1,4 @@
-import osrf.cache, osrf.json, osrf.ses
+import osrf.cache, osrf.json, osrf.ses, osrf.net_obj
import oils.const, oils.utils.utils, oils.event
class PicklistMgr(object):
@@ -67,6 +67,36 @@
return entry
+ def create_or_replace(self, pl_name):
+
+ # find and delete any existing picklist with the requested name
+ data = self.ses.request(
+ 'open-ils.acq.picklist.name.retrieve',
+ self.request_mgr.ctx.core.authtoken, pl_name).recv()
+ if data:
+ picklist = data.content()
+ status = self.ses.request(
+ 'open-ils.acq.picklist.delete',
+ self.request_mgr.ctx.core.authtoken, picklist.id()).recv().content()
+ oils.event.Event.parse_and_raise(status)
+
+ # create the new one
+ picklist = osrf.net_obj.NetworkObject.acqpl()
+ picklist.name(pl_name)
+ picklist.owner(self.request_mgr.ctx.core.user.id())
+ picklist = self.ses.request(
+ 'open-ils.acq.picklist.create',
+ self.request_mgr.ctx.core.authtoken, picklist).recv().content()
+ oils.event.Event.parse_and_raise(picklist)
+ return picklist
+
+ def create_entry(self, entry):
+ status = self.ses.request(
+ 'open-ils.acq.picklist_entry.create',
+ self.request_mgr.ctx.core.authtoken, entry).recv().content()
+ oils.event.Event.parse_and_raise(status)
+ return status
+
@staticmethod
def find_entry_attr(entry, attr_name, attr_type='picklist_marc_attr_definition'):
for entry_attr in entry.attributes():
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py 2008-01-18 15:54:51 UTC (rev 8419)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/search.py 2008-01-18 19:57:04 UTC (rev 8420)
@@ -1,10 +1,7 @@
-import os, md5
-import oilsweb.lib.context
-import osrf.ses
-import osrf.xml_obj
-import oils.const
-import osrf.log, osrf.cache, osrf.json
+import os, md5, time
import pylons.config
+import osrf.ses, osrf.net_obj
+import oils.const, oilsweb.lib.acq.picklist
EG_Z39_SOURCES = 'open-ils.search.z3950.retrieve_services'
EG_Z39_SEARCH = 'open-ils.search.z3950.search_class'
@@ -15,24 +12,53 @@
if _z_sources:
return _z_sources
_z_sources = osrf.ses.ClientSession.atomic_request(
- 'open-ils.search', EG_Z39_SOURCES, ctx.core.authtoken)
+ oils.const.OILS_APP_SEARCH, EG_Z39_SOURCES, ctx.core.authtoken)
return _z_sources
-def multi_search(ctx, search):
+def multi_search(request_mgr, search):
ses = osrf.ses.ClientSession(oils.const.OILS_APP_SEARCH)
- req = ses.request(EG_Z39_SEARCH, ctx.core.authtoken, search)
+ req = ses.request(EG_Z39_SEARCH, request_mgr.ctx.core.authtoken, search)
+ pl_manager = oilsweb.lib.acq.picklist.PicklistMgr(request_mgr)
+ picklist_id = pl_manager.create_or_replace("__search_tmp__")
+
while not req.complete:
- resp = req.recv(60)
+ resp = req.recv()
if not resp:
break
+
res = resp.content()
- for rec in res['records']:
- rec['extracts'] = flatten_record(rec['marcxml'])
- rec['cache_id'] = cache_id
- cache_id += 1
+ for record in res['records']:
+ entry = osrf.net_obj.NetworkObject.acqple()
+ entry.picklist(picklist_id)
+ entry.source_label(res['service'])
+ entry.marc(record['marcxml'])
+ entry.eg_bib_id(record.get('bibid'))
+ pl_manager.create_entry(entry)
- results.append(res)
+ return picklist_id
- return results, cache_search(search, results)
+def compile_multi_search(request_mgr):
+ search = {
+ 'service' : [],
+ 'username' : [],
+ 'password' : [],
+ 'search' : {},
+ 'limit' : request_mgr.ctx.acq.limit,
+ 'offset' : request_mgr.ctx.acq.offset
+ }
+
+ # collect the sources and credentials
+ for src in request_mgr.ctx.acq.search_source:
+ search['service'].append(src)
+ search['username'].append("") # XXX config values? in-db?
+ search['password'].append("") # XXX config values? in-db?
+
+ # collect the search classes
+ for cls in request_mgr.ctx.acq.search_class:
+ if request_mgr.request.params[cls]:
+ search['search'][cls] = request_mgr.request.params[cls]
+
+ return search
+
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/picklist_entry_summary.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/picklist_entry_summary.html 2008-01-18 15:54:51 UTC (rev 8419)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/picklist_entry_summary.html 2008-01-18 19:57:04 UTC (rev 8420)
@@ -2,8 +2,10 @@
${_('Picklist Entry')}
<div class='oils-acq-picklist-entry-attributes'>
<%
+ provider = c.oils.acq.picklist_entry.provider() or ''
+ if provider: provider.name()
meta = _("Source %(data)s") % {"data":c.oils.acq.picklist_entry.source_label()}
- meta2 = _("Provider %(data)s") % {"data":c.oils.acq.picklist_entry.provider().name()}
+ meta2 = _("Provider %(data)s") % {"data":provider}
meta3 = _("Create date %(data)s") % {"data":c.oils.acq.picklist_entry.create_time()}
meta4 = _("Last update time %(data)s") % {"data":c.oils.acq.picklist_entry.edit_time()}
%>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/search.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/search.html 2008-01-18 15:54:51 UTC (rev 8419)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/search.html 2008-01-18 19:57:04 UTC (rev 8420)
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-<%inherit file='base.html'/>
+<%inherit file='../base.html'/>
<%def name="page_title()">${_('Evergreen Acquisitions Search')}</%def>
<%def name="block_content()">
- <form method='GET' action='pl_builder'>
+ <form method='GET' action='${c.oils.acq.prefix}/picklist/do_search'>
<div id='oils-acq-search-block' class='container'>
<div id='oils-acq-search-sources-block'>
<div id='oils-acq-search-sources-label'>${_('Search Sources')}</div>
@@ -15,8 +15,7 @@
<ul class='oils-acq-search-sources-sublist'>
% for src,cfg in c.oils.acq.z39_sources.iteritems():
<li>
- <input type='checkbox' name='${c.oils.acq.search_source_.cgi_name}'
- value='${src}'>
+ <input type='checkbox' name='${c.oils.acq.search_source_.cgi_name}' value='${src}'>
${src} ${cfg["host"]}:${cfg["db"]}
% if cfg['auth'] == 't':
<span class='oils-acq-search-source-auth'>*</span>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/navigate.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/navigate.html 2008-01-18 15:54:51 UTC (rev 8419)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/navigate.html 2008-01-18 19:57:04 UTC (rev 8420)
@@ -2,7 +2,7 @@
<table id='oils-base-navigate-table'>
<tbody>
<tr><td><a href='${c.oils.core.prefix}/base/dashboard'>${_('Dashboard')}</a></td></tr>
- <tr><td><a href='${c.oils.core.prefix}/acq/index'>${_('Acquisitions')}</a></td></tr>
+ <tr><td><a href='${c.oils.core.prefix}/acq/base/index'>${_('Acquisitions')}</a></td></tr>
<tr><td><a href='${c.oils.core.prefix}/ser/index'>${_('Serials')}</a></td></tr>
<tr><td><a href='${c.oils.core.prefix}/admin/index'>${_('Admin')}</a></td></tr>
</tbody>
More information about the open-ils-commits
mailing list