Fixed a few bugs that occurred if you did not have OPENSRF_STAFF_USERID defined.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 3 Apr 2011 00:53:54 +0000 (00:53 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 3 Apr 2011 00:53:54 +0000 (00:53 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1304 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/integration/evergreen_site.py
conifer/syrup/views/items.py

index 7554bf7..c891980 100644 (file)
@@ -220,8 +220,8 @@ class EvergreenIntegration(object):
     OSRF_CAT_SEARCH_ORG_UNIT = getattr(settings, 'OSRF_CAT_SEARCH_ORG_UNIT', None)
 
     def cat_search(self, query, start=1, limit=10):
-        barcode = 0
-        bibid  = 0
+        barcode = ''
+        bibid  = ''
         is_barcode = re.search('\d{14}', query)
 
         if query.startswith(self.EG_BASE):
index 39dea4f..a0a55f0 100644 (file)
@@ -7,7 +7,7 @@ from xml.etree                   import ElementTree as ET
 from collections                 import defaultdict
 from conifer.libsystems.evergreen.support import initialize, E1
 
-if getattr(settings, 'OPENSRF_STAFF_USERID'): # TODO: we need an explicit 'we do updates' flag
+if hasattr(settings, 'OPENSRF_STAFF_USERID'): # TODO: we need an explicit 'we do updates' flag
     from conifer.libsystems.evergreen import opensrf
 
 @members_only
@@ -297,8 +297,9 @@ def item_add_cat_search(request, site_id, item_id):
         except:
             pubdate = ''
 
-        bibid = bib_id=request.POST.get('bibid')
-        bc = None
+        bibid   = bib_id=request.POST.get('bibid', '')
+        bar_num = request.POST.get('bc', '')
+        barcode = None
 
         # TODO: the Leddy stuff here belongs in an integration-module function. [GF]
 
@@ -309,19 +310,17 @@ def item_add_cat_search(request, site_id, item_id):
         eg_location = ''
 
         #TODO: use python bindings for these interactions
-        bar_num=request.POST.get('bc')
-        if bar_num and getattr(settings, 'OPENSRF_STAFF_USERID'): # TODO: we need an explicit 'we do updates' flag
-            bc = bar_num
-            eg_modifier, eg_location, eg_callno = opensrf.ils_item_info(bc)
-
-        if bibid > 0:
+        if bar_num and hasattr(settings, 'OPENSRF_STAFF_USERID'): # TODO: we need an explicit 'we do updates' flag
+            barcode = bar_num
+            eg_modifier, eg_location, eg_callno = opensrf.ils_item_info(barcode)
+        if bibid:
             item = site.item_set.create(parent_heading=parent_item,
                                         title=dublin.get('dc:title','Untitled'),
                                         author=dublin.get('dc:creator'),
                                         publisher=dublin.get('dc:publisher',''),
                                         published=pubdate,
                                         bib_id = bibid,
-                                        barcode = bc,
+                                        barcode = barcode,
                                         circ_modifier = eg_modifier,
                                         circ_desk = eg_location,
                                         orig_callno = eg_callno,
@@ -333,9 +332,9 @@ def item_add_cat_search(request, site_id, item_id):
                                         author=dublin.get('dc:creator'),
                                         publisher=dublin.get('dc:publisher',''),
                                         published=pubdate,
-                                        barcode = bc,
+                                        barcode = barcode,
                                         circ_modifier = eg_modifier,
-                                        circ_desk = eg_desk,
+                                        circ_desk = eg_location,
                                         orig_callno = eg_callno,
                                         marcxml=raw_pickitem,
                                         **dct)