show MARC for matching items on 'mark-item-arrived' screen.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 5 Apr 2009 23:38:32 +0000 (23:38 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 5 Apr 2009 23:38:32 +0000 (23:38 +0000)
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

conifer/libsystems/evergreen/support.py
conifer/syrup/models.py
conifer/syrup/views.py
conifer/templates/phys/mark_arrived.xhtml
conifer/templates/phys/mark_arrived_choose.xhtml
conifer/templates/phys/mark_arrived_outcome.xhtml

index df87491..4e4454f 100644 (file)
@@ -70,7 +70,9 @@ def evergreen_request(method, *args, **kwargs):
 
 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]
index 70353b7..96ef4ae 100644 (file)
@@ -10,6 +10,7 @@ from conifer.custom import course_sections # fixme, not sure if conifer.custom i
 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>'):
@@ -409,6 +410,10 @@ class Item(m.Model):
     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()
index bd3eabc..39f7237 100644 (file)
@@ -1334,8 +1334,11 @@ def phys_mark_arrived(request):
             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)
index fdaf920..4f52eab 100644 (file)
@@ -1,5 +1,4 @@
 <?python
-sample_item = '31862016799294'  # fixme, just for testing.
 title = _('Mark Items as Arrived')
 ?>
 <html xmlns="http://www.w3.org/1999/xhtml"
@@ -24,7 +23,7 @@ title = _('Mark Items as Arrived')
       <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>
index cde15bb..bd0d6c7 100644 (file)
@@ -1,6 +1,5 @@
 <?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"
@@ -46,16 +45,34 @@ title = _('Mark Items as Arrived: Choose Match')
       <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 &lt; 5 and 'likely' or score &lt; 50 and 'maybe' or 'doubtful'}">
+      <tbody py:for="n, (score, item) in enumerate(ranked)"
+         class="${score &lt; 5 and 'likely' or score &lt; 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 '&mdash;'}</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>
index f022efe..205ba94 100644 (file)
@@ -17,5 +17,6 @@ title = _('Matches saved; item marked as received')
 </head>
 <body>
   <h1>${title}</h1>
+  <p><a href="../">Continue</a></p>
 </body>
 </html>