From 547379bf106b5f98c2e383d62ccfa32eaf6f5b6f Mon Sep 17 00:00:00 2001 From: artunit Date: Fri, 14 Jan 2011 06:25:43 +0000 Subject: [PATCH] snag bibid from url search git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1196 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/integration/uwindsor.py | 8 +++++++- conifer/syrup/views/items.py | 5 +++-- conifer/templates/item/item_add_cat_search.xhtml | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/conifer/integration/uwindsor.py b/conifer/integration/uwindsor.py index 72a11a6..65b7a31 100644 --- a/conifer/integration/uwindsor.py +++ b/conifer/integration/uwindsor.py @@ -155,8 +155,14 @@ def _item_status(bib_id): return None def cat_search(query, start=1, limit=10): + bibid=0 if query.startswith(EG_BASE): # query is an Evergreen URL + # snag the bibid at this point + params = dict([x.split("=") for x in query.split("&")]) + for key in params.keys(): + if key.find('?r') != -1: + bibid = params[key] results = M.marcxml_to_records(I.url_to_marcxml(query)) numhits = len(results) else: @@ -176,7 +182,7 @@ def cat_search(query, start=1, limit=10): tree = M.marcxml_to_records(marc)[0] results.append(tree) numhits = int(superpage['count']) - return results, numhits + return results, numhits, bibid def bib_id_to_marcxml(bib_id): """ diff --git a/conifer/syrup/views/items.py b/conifer/syrup/views/items.py index ea74f01..6223ed6 100644 --- a/conifer/syrup/views/items.py +++ b/conifer/syrup/views/items.py @@ -244,11 +244,11 @@ def item_add_cat_search(request, site_id, item_id): site=site, parent_item=parent_item) query = request.GET.get('query','').strip() start, limit = (int(request.GET.get(k,v)) for k,v in (('start',1),('limit',10))) - results, numhits = integration.cat_search(query, start, limit) + results, numhits, bibid = integration.cat_search(query, start, limit) return g.render('item/item_add_cat_search.xhtml', results=results, query=query, start=start, limit=limit, numhits=numhits, - site=site, parent_item=parent_item) + site=site, parent_item=parent_item, bibid=bibid) else: # User has selected an item; add it to site. raw_pickitem = request.POST.get('pickitem', '').strip() @@ -298,6 +298,7 @@ def item_add_cat_search(request, site_id, item_id): author=dublin.get('dc:creator'), publisher=dublin.get('dc:publisher',''), published=pubdate, + bib_id=request.POST.get('bibid'), marcxml=raw_pickitem, **dct) item.save() diff --git a/conifer/templates/item/item_add_cat_search.xhtml b/conifer/templates/item/item_add_cat_search.xhtml index 87c6385..6b89d7c 100644 --- a/conifer/templates/item/item_add_cat_search.xhtml +++ b/conifer/templates/item/item_add_cat_search.xhtml @@ -75,6 +75,7 @@ dc_keys = ['dc:title', 'dc:creator', 'dc:publisher', 'dc:date']
+
-- 2.11.0