So, in a thorny case, you can match the barcode-swiped item's bib
record against those in the database.
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@284
6d9bc8c9-1ec2-4278-b937-
99fde70a366f
def evergreen_request_single_result(method, *args):
resp = evergreen_request(method, *args)
- if len(resp) > 1:
+ if not resp:
+ return None
+ elif len(resp) > 1:
warnings.warn('taking single value from multivalue evergreen response')
print >> sys.stderr, repr(resp)
return resp[0]
from conifer.custom import lib_integration
import re
import random
+from django.utils import simplejson
def highlight(text, phrase,
highlighter='<strong class="highlight">\\1</strong>'):
def barcode(self):
bc = self.metadata_set.filter(name='syrup:barcode')
return bc and bc[0].value or None
+
+ def marc(self):
+ m = self.metadata_set.filter(name='syrup:marc')
+ return m and simplejson.loads(m[0].value) or None
def smallint(self):
bc = self.barcode()
msg = _('This item has already been marked as received. Date received: %s')
msg = msg % str(already.received)
return simple_message(_('Item already marked as received'), msg)
-
bib_id = lib_integration.barcode_to_bib_id(barcode)
+ if not bib_id:
+ return simple_message(_('Item not found'),
+ _('No item matching this barcode could be found.'))
+
marcxml = lib_integration.bib_id_to_marcxml(bib_id)
dct = marcxml_to_dictionary(marcxml)
dublin = marcxml_dictionary_to_dc(dct)
<?python
-sample_item = '31862016799294' # fixme, just for testing.
title = _('Mark Items as Arrived')
?>
<html xmlns="http://www.w3.org/1999/xhtml"
<tr>
<th>Item Barcode</th>
<td>
- <input type="text" id="item" name="item" style="width: 400;" value="${sample_item}"/>
+ <input type="text" id="item" name="item" style="width: 400;" value=""/>
</td>
</tr>
<tr>
<?python
import re
-sample_item = '31862016799294' # fixme, just for testing.
title = _('Mark Items as Arrived: Choose Match')
?>
<html xmlns="http://www.w3.org/1999/xhtml"
<thead style="font-size: 70%;">
<tr><th py:for="v in 'Select Title Author Course Instructor Score'.split(' ')">${v}</th></tr>
</thead>
- <tbody>
- <tr py:for="score, item in ranked" class="${score < 5 and 'likely' or score < 50 and 'maybe' or 'doubtful'}">
+ <tbody py:for="n, (score, item) in enumerate(ranked)"
+ class="${score < 5 and 'likely' or score < 50 and 'maybe' or 'doubtful'}"
+ py:with="marc=item.marc()">
+ <tr>
<td><input type="checkbox" name="choose_${item.id}" id="choose_${item.id}"/></td>
- <td><label for="choose_${item.id}">${item}</label></td>
- <td>${item.author()}</td>
+ <td><label for="choose_${item.id}">${item}</label>
+ <span py:if="marc"><a href="javascript:$('#marcdata${n}').toggle();void(0);">detail</a></span>
+ </td>
+ <td>${item.author() or '—'}</td>
<td>${item.course.title}</td>
<td>${','.join(n.last_name for n in item.course.get_instructors())}</td>
<td>${repr(score)}</td>
</tr>
- </tbody>
+ <tr id="marcdata${n}" style="display: none;">
+ <td/>
+ <td colspan="3">
+ <div>
+ <?python keys=marc.keys(); keys.sort() ?>
+ <table>
+ <tr py:for="k in keys">
+ <th>${k}</th>
+ <td>${marc[k]}</td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </tbody>
</table>
</form>
</div>
</head>
<body>
<h1>${title}</h1>
+ <p><a href="../">Continue</a></p>
</body>
</html>