[open-ils-commits] r1271 - in servres/trunk/conifer: integration static syrup syrup/views templates/item (artunit)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Mar 20 21:47:43 EDT 2011
Author: artunit
Date: 2011-03-20 21:47:41 -0400 (Sun, 20 Mar 2011)
New Revision: 1271
Modified:
servres/trunk/conifer/integration/uwindsor.py
servres/trunk/conifer/static/main.css
servres/trunk/conifer/syrup/models.py
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views/items.py
servres/trunk/conifer/templates/item/common_metadata.xhtml
servres/trunk/conifer/templates/item/item_add_cat_search.xhtml
Log:
evergreen updates, folded in with item screen
Modified: servres/trunk/conifer/integration/uwindsor.py
===================================================================
--- servres/trunk/conifer/integration/uwindsor.py 2011-03-20 20:32:48 UTC (rev 1270)
+++ servres/trunk/conifer/integration/uwindsor.py 2011-03-21 01:47:41 UTC (rev 1271)
@@ -229,7 +229,8 @@
def cat_search(query, start=1, limit=10):
bibid=0
- bc = re.search('\d{14}', query.strip())
+ barcode = re.search('\d{14}', query.strip())
+ bc = 0
if query.startswith(EG_BASE):
# query is an Evergreen URL
# snag the bibid at this point
@@ -239,17 +240,21 @@
bibid = params[key]
results = M.marcxml_to_records(I.url_to_marcxml(query))
numhits = len(results)
- elif bc:
+ elif barcode:
results = []
numhits = 0
# print "bc", bc.group(0)
- bib = E1('open-ils.search.bib_id.by_barcode', bc.group(0))
+ bc = barcode.group(0)
+ bib = E1('open-ils.search.bib_id.by_barcode', bc)
if bib:
bibid = bib
- # print "bibid", bib
+ print "bibid", bib
copy = E1('open-ils.supercat.record.object.retrieve', bib)
+ print "copy", copy
rec = copy[0]
+ print "rec", rec
marc = unicode(rec['marc'], 'utf-8')
+ print "marc", marc
tree = M.marcxml_to_records(marc)[0]
results.append(tree)
numhits = 1
@@ -270,7 +275,7 @@
tree = M.marcxml_to_records(marc)[0]
results.append(tree)
numhits = int(superpage['count'])
- return results, numhits, bibid
+ return results, numhits, bibid, bc
def bib_id_to_marcxml(bib_id):
"""
Modified: servres/trunk/conifer/static/main.css
===================================================================
--- servres/trunk/conifer/static/main.css 2011-03-20 20:32:48 UTC (rev 1270)
+++ servres/trunk/conifer/static/main.css 2011-03-21 01:47:41 UTC (rev 1271)
@@ -307,6 +307,8 @@
#breadcrumbs { margin: 8px 0px 16px 0; width: 716px;
text-indent: -24px; padding-left: 24px; }
+.cat_opts { background-color: #f2e4cc;}
+
.errorlist { float: right; }
.errorlist li { color: red; font-size: 90%; }
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2011-03-20 20:32:48 UTC (rev 1270)
+++ servres/trunk/conifer/syrup/models.py 2011-03-21 01:47:41 UTC (rev 1271)
@@ -604,8 +604,20 @@
pages = m.CharField(max_length=64, null=True, blank=True)
# isbn or issn (not validated)
isbn = m.CharField(max_length=17, null=True, blank=True)
+ #barcode
+ barcode = m.CharField(max_length=14, null=True, blank=True)
+ #orig_callno: this is a copy of the call number associated with the barcode
+ orig_callno = m.CharField(max_length=64, null=True, blank=True)
+ # TODO: all of the choices should probably go in settings, as per EVERGREEN_UPDATE_CHOICES
+ # Options for evergreen updates
+ EVERGREEN_UPDATE_CHOICES = settings.UPDATE_CHOICES
+
+ evergreen_update = m.CharField(max_length=4,
+ choices=EVERGREEN_UPDATE_CHOICES,
+ default='One')
+
# As per discussion with Art Rhyno and Joan Dalton, Leddy Library.
COPYRIGHT_STATUS_CHOICES = [
('UK', 'unknown'),
@@ -619,6 +631,29 @@
choices=COPYRIGHT_STATUS_CHOICES,
default='UK')
+ # Options for circ modifiers
+ CIRC_MODIFIER_CHOICES = [
+ ('CIRC', 'Normal'),
+ ('RSV2', '2 Hour'),
+ ('RSV1', '1 Day'),
+ ('RSV3', '3 Day'),
+ ('RSV7', '7 Day'),
+ ]
+
+ circ_modifier = m.CharField(max_length=10,
+ choices=CIRC_MODIFIER_CHOICES,
+ default='RSV2')
+
+ # Options for circ desk
+ CIRC_DESK_CHOICES = [
+ ('631', 'Reserves Counter'),
+ ('598', 'Circulating Collection'),
+ ]
+
+ circ_desk = m.CharField(max_length=5,
+ choices=CIRC_DESK_CHOICES,
+ default='631')
+
ITEMTYPE_CHOICES = [
# From http://www.oclc.org/bibformats/en/fixedfield/type.shtm.
# It is hoped that this can be harvested from the 006 field in
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2011-03-20 20:32:48 UTC (rev 1270)
+++ servres/trunk/conifer/syrup/urls.py 2011-03-21 01:47:41 UTC (rev 1271)
@@ -8,6 +8,7 @@
urlpatterns = patterns('conifer.syrup.views',
(r'^$', 'welcome'),
+ (r'^test/$', 'item_ils_update_test'),
(r'^site/$', 'my_sites'),
(r'^site/new/$', 'add_new_site'),
(r'^site/invitation/$', 'site_invitation'),
Modified: servres/trunk/conifer/syrup/views/items.py
===================================================================
--- servres/trunk/conifer/syrup/views/items.py 2011-03-20 20:32:48 UTC (rev 1270)
+++ servres/trunk/conifer/syrup/views/items.py 2011-03-21 01:47:41 UTC (rev 1271)
@@ -10,32 +10,61 @@
from conifer.libsystems.evergreen.opensrf import *
@instructors_only
-def item_ils_update(request):
+def item_ils_update_test(request):
"""Update item in ILS"""
# this works in my tests, need to try more variations
# disable in production for now
- return simple_message(_('testing.'), _('testing.'))
+ circ_mods = settings.EVERGREEN_CIRC_MODS
+ # for circ_modifier in circ_mods:
+
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 will come from form
barcode = "31862005297755"
barcode_copy = E1(settings.OPENSRF_CN_BARCODE, token, barcode);
copy = None
if barcode_copy:
+ volumeinfo = barcode_copy.get("volume")
+ if volumeinfo:
+ volume = volumeinfo['__p']
+ print "volume", volume
+ print "call", volume[7]
+ volume[0] = []
+ volume[5] = 1
+ volume[7] = "QA76.74.M63 B45 2010"
+ volume[13] = None
+ volume.append(None)
+ volume.append('1')
+ print "WOULD UPDATE", volume
+ # updaterec = E1("open-ils.actor.user.perm.check.multi_org", token, 104965, [109], ["UPDATE_VOLUME"])
+ # print "updaterec", updaterec
+ updaterec = E1(settings.OPENSRF_VOLUME_UPDATE, token, [{"__c":"acn","__p":volume}], false, {"auto_merge_vols":false})
+ print "updaterec", updaterec
+ session_cleanup(token)
+ return simple_message(_('testing.'), _('testing.'))
+ if barcode_copy:
copy = barcode_copy.get("copy")
if copy:
+ print "copy", copy
detailid = copy['__p'][21]
details = E1(settings.OPENSRF_FLESHEDCOPY_CALL, [detailid])
print "details", details
location = details[0]['__p'][23]['__p'][3]
- details[0]['__p'][6] = "CIRC"
+ # details[0]['__p'][6] = "RSV1"
+ details[0]['__p'][6] = circ_mods[0]
+ print "location", location
details[0]['__p'][23] = location
+ details[0]['__p'][23] = settings.EVERGREEN_RSV_DESK
+ #the joy 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')
- updaterec = E1(settings.OPENSRF_BATCH_UPDATE, token, details,true)
- print "updaterec", updaterec
+ print "WOULD UPDATE", details
+ # updaterec = E1(settings.OPENSRF_BATCH_UPDATE, token, details,true)
+ # print "updaterec", updaterec
session_cleanup(token)
return simple_message(_('testing.'), _('testing.'))
@@ -277,11 +306,11 @@
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, bibid = integration.cat_search(query, start, limit)
+ results, numhits, bibid, bc = 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, bibid=bibid)
+ site=site, parent_item=parent_item, bibid=bibid, bc=bc)
else:
# User has selected an item; add it to site.
raw_pickitem = request.POST.get('pickitem', '').strip()
@@ -327,6 +356,34 @@
pubdate = ''
bibid = bib_id=request.POST.get('bibid')
+ bc = None
+ callno = None
+ eg_modifier = None
+ eg_desk = None
+
+ bar_num=request.POST.get('bc')
+ if bar_num and settings.OPENSRF_STAFF_USERID:
+ bc = bar_num
+ token = auth_token(settings.OPENSRF_STAFF_USERID, settings.OPENSRF_STAFF_PW,
+ settings.OPENSRF_STAFF_ORG, settings.OPENSRF_STAFF_WORKSTATION)
+ barcode_copy = E1(settings.OPENSRF_CN_BARCODE, token, bc);
+ if barcode_copy:
+ volumeinfo = barcode_copy.get("volume")
+ copyinfo = barcode_copy.get("copy")
+ if volumeinfo:
+ volume = volumeinfo['__p']
+ if volume:
+ callno = volume[7]
+ if copyinfo:
+ detailid = copyinfo['__p'][21]
+ details = E1(settings.OPENSRF_FLESHEDCOPY_CALL, [detailid])
+ if details:
+ eg_desk = details[0]['__p'][23]['__p'][3]
+ print "eg_desk", eg_desk
+ eg_modifier = details[0]['__p'][6]
+
+ session_cleanup(token)
+
if bibid > 0:
item = site.item_set.create(parent_heading=parent_item,
title=dublin.get('dc:title','Untitled'),
@@ -334,6 +391,10 @@
publisher=dublin.get('dc:publisher',''),
published=pubdate,
bib_id = bibid,
+ barcode = bc,
+ circ_modifier = eg_modifier,
+ circ_desk = eg_desk,
+ orig_callno = callno,
marcxml=raw_pickitem,
**dct)
else:
@@ -342,6 +403,10 @@
author=dublin.get('dc:creator'),
publisher=dublin.get('dc:publisher',''),
published=pubdate,
+ barcode = bc,
+ circ_modifier = eg_modifier,
+ circ_desk = eg_desk,
+ orig_callno = callno,
marcxml=raw_pickitem,
**dct)
item.save()
@@ -383,6 +448,29 @@
if 'author2' in data:
del data['author2']
[setattr(item, k, v) for (k,v) in data.items()]
+
+ if item.item_type == 'PHYS':
+ update_option = request.POST.get('update_option')
+ location_option = request.POST.get('location_option')
+ modifier_option = request.POST.get('modifier_option')
+ update_status = True
+
+ if update_option == 'Cat':
+ update_status = evergreen_item_update(item.barcode, item.orig_callno,
+ modifier_option, location_option)
+
+ #leave values alone if update failed
+ if update_status:
+ item.evergreen_update = update_option
+ item.circ_desk = location_option
+ item.circ_modifier = modifier_option
+
+ if update_option == 'None':
+ item.evergreen_update = ''
+ item.barcode = ''
+ item.orig_callno = ''
+ item.circ_modifier = ''
+ item.circ_desk = ''
item.save()
return HttpResponseRedirect(item.parent_url())
@@ -492,3 +580,60 @@
return HttpResponseRedirect(new_parent.item_url('meta'))
else:
return HttpResponseRedirect(site.site_url())
+
+ at 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
Modified: servres/trunk/conifer/templates/item/common_metadata.xhtml
===================================================================
--- servres/trunk/conifer/templates/item/common_metadata.xhtml 2011-03-20 20:32:48 UTC (rev 1270)
+++ servres/trunk/conifer/templates/item/common_metadata.xhtml 2011-03-21 01:47:41 UTC (rev 1271)
@@ -35,6 +35,57 @@
</select>
</td>
</tr>
+ <tr py:if="user.is_staff and item.item_type == 'PHYS'">
+ <th>Catalogue Settings</th>
+ <td>
+ <table>
+ <tbody>
+ <tr>
+ <th>Update</th>
+ <td class="cat_opts">
+ <select name="update_option">
+ <option py:for="k,v in item.EVERGREEN_UPDATE_CHOICES"
+ py:attrs="{'selected': item.evergreen_update==k or None}"
+ value="${k}" py:content="v"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th>Barcode</th>
+ <td class="cat_opts">
+ <input type="text" name="barcode" value="${item.barcode}"/>
+ </td>
+ </tr>
+ <tr>
+ <th>Location</th>
+ <td class="cat_opts">
+ <select name="location_option">
+ <option py:for="k,v in item.CIRC_DESK_CHOICES"
+ py:attrs="{'selected': item.circ_desk==k or None}"
+ value="${k}" py:content="v"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th>Modifier</th>
+ <td class="cat_opts">
+ <select name="modifier_option">
+ <option py:for="k,v in item.CIRC_MODIFIER_CHOICES"
+ py:attrs="{'selected': item.circ_modifier==k or None}"
+ value="${k}" py:content="v"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th>Call Number</th>
+ <td class="cat_opts">
+ <input type="text" name="orig_callno" value="${item.orig_callno}"/>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
</tbody>
</html>
Modified: servres/trunk/conifer/templates/item/item_add_cat_search.xhtml
===================================================================
--- servres/trunk/conifer/templates/item/item_add_cat_search.xhtml 2011-03-20 20:32:48 UTC (rev 1270)
+++ servres/trunk/conifer/templates/item/item_add_cat_search.xhtml 2011-03-21 01:47:41 UTC (rev 1271)
@@ -76,6 +76,7 @@
<form action="." method="POST">
<!-- !TODO: is utf8 okay here? I shouldn't have to do any decoding here. -->
<input type="hidden" name="bibid" value="${bibid}"/>
+ <input type="hidden" name="bc" value="${bc}"/>
<input type="hidden" name="pickitem" value="${ET.tostring(res)}"/>
<input type="submit" value="Pick this item"/>
</form>
More information about the open-ils-commits
mailing list