From: artunit Date: Tue, 22 Mar 2011 01:53:53 +0000 (+0000) Subject: yet again with location, modifier, and call number updates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5ec08f8adf62846da2d8bcb3e3373beb1777fa14;p=syrup%2Fmasslnc.git yet again with location, modifier, and call number updates git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1272 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/libsystems/evergreen/opensrf.py b/conifer/libsystems/evergreen/opensrf.py index 87904f0..a1c704f 100644 --- a/conifer/libsystems/evergreen/opensrf.py +++ b/conifer/libsystems/evergreen/opensrf.py @@ -27,6 +27,8 @@ def auth_token(username, password, org, workstation): print "*** print_exc:" traceback.print_exc() pass # fail silently in production + return None + return authtoken def session_cleanup(authtoken): @@ -37,5 +39,64 @@ def session_cleanup(authtoken): print "*** print_exc:" traceback.print_exc() pass # fail silently in production + return None return True + +def evergreen_item_update(barcode, callno, modifier, desk): + try: + token = auth_token(settings.OPENSRF_STAFF_USERID, settings.OPENSRF_STAFF_PW, + settings.OPENSRF_STAFF_ORG, settings.OPENSRF_STAFF_WORKSTATION) + + null = None + true = True + false = False + barcode_copy = E1(settings.OPENSRF_CN_BARCODE, token, barcode); + + copy = None + volumeinfo = None + + if barcode_copy: + volumeinfo = barcode_copy.get("volume") + if volumeinfo: + volume = volumeinfo['__p'] + if volume and volume[7] != callno: + volume[0] = [] + volume[7] = str(callno) + vol_len = len(volume) - 1 + volume[vol_len] = str(volume[vol_len]) + # ok, this is bad, need to find what these values are + for i in range(0, 4): + volume.append(None) + volume.append('1') + # print "volume", volume + updaterec = E1(settings.OPENSRF_VOLUME_UPDATE, + token, [{"__c":"acn","__p":volume}], false, + {"auto_merge_vols":false}) + # print "update", updaterec + copy = barcode_copy.get("copy") + if copy: + # print "copy", copy + detailid = copy['__p'][21] + details = E1(settings.OPENSRF_FLESHEDCOPY_CALL, [detailid]) + if details and (details[0]['__p'][7] != modifier or details[0]['__p'][23] != desk): + details[0]['__p'][7] = str(modifier) + details[0]['__p'][23] = str(desk) + # ditto here too, need to find what these values are + for i in range(0, 6): + details[0]['__p'].append(None) + details[0]['__p'].append('1') + + print "details", details + updaterec = E1(settings.OPENSRF_BATCH_UPDATE, token, details,true) + # print "updaterec", updaterec + + session_cleanup(token) + except: + print "item update problem" + print "*** print_exc:" + traceback.print_exc() + pass # fail silently in production + return False + + return True diff --git a/conifer/syrup/views/items.py b/conifer/syrup/views/items.py index 078a914..5dec0eb 100644 --- a/conifer/syrup/views/items.py +++ b/conifer/syrup/views/items.py @@ -464,6 +464,9 @@ def item_edit(request, site_id, item_id): item.evergreen_update = update_option item.circ_desk = location_option item.circ_modifier = modifier_option + else: + return simple_message(_('Unable to update'), + _('Sorry, unable to update at this time, please try again.')) if update_option == 'None': item.evergreen_update = '' @@ -580,60 +583,3 @@ def item_relocate(request, site_id, item_id): return HttpResponseRedirect(new_parent.item_url('meta')) else: return HttpResponseRedirect(site.site_url()) - -@instructors_only -def evergreen_item_update(barcode, callno, modifier, desk): - try: - token = auth_token(settings.OPENSRF_STAFF_USERID, settings.OPENSRF_STAFF_PW, - settings.OPENSRF_STAFF_ORG, settings.OPENSRF_STAFF_WORKSTATION) - print "token", token - null = None - true = True - false = False - barcode_copy = E1(settings.OPENSRF_CN_BARCODE, token, barcode); - copy = None - volumeinfo = None - if barcode_copy: - volumeinfo = barcode_copy.get("volume") - if volumeinfo: - volume = volumeinfo['__p'] - if volume and volume[7] != callno: - volume[0] = [] - volume[5] = 1 - volume[7] = callno.encode('ascii') - print "callno", callno - volume[13] = None - volume.append(None) - volume.append('1') - print "WOULD UPDATE", volume - updaterec = E1(settings.OPENSRF_VOLUME_UPDATE, - token, [{"__c":"acn","__p":volume}], false, - {"auto_merge_vols":false}) - print "updaterec", updaterec - copy = barcode_copy.get("copy") - if copy: - print "copy", copy - detailid = copy['__p'][21] - details = E1(settings.OPENSRF_FLESHEDCOPY_CALL, [detailid]) - print "details", details - if details and (details[0]['__p'][6] != modifier or details[0]['__p'][23] != desk): - details[0]['__p'][6] = modifier - details[0]['__p'][23] = desk - - #the value of testing, these are in the fm_IDL.xml for RC but not production (total circ and holds) - details[0]['__p'].append(None) - details[0]['__p'].append('1') - - print "WOULD UPDATE", details - updaterec = E1(settings.OPENSRF_BATCH_UPDATE, token, details,true) - print "updaterec", updaterec - - session_cleanup(token) - except: - print "item update problem" - print "*** print_exc:" - traceback.print_exc() - pass # fail silently in production - return False - - return True