embed status information for all copies
authorartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 9 Feb 2011 05:23:25 +0000 (05:23 +0000)
committerartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 9 Feb 2011 05:23:25 +0000 (05:23 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1225 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/integration/uwindsor.py
conifer/syrup/models.py
conifer/templates/components/site.xhtml

index dde1e7d..b765aee 100644 (file)
@@ -99,6 +99,8 @@ def _item_status(bib_id):
            dueinfo = ''
             callno = ''
             circmod = ''
+            alldues = []
+
             for org, callnum, loc, stats in counts:
                callprefix = ''
                callsuffix = ''
@@ -119,32 +121,41 @@ def _item_status(bib_id):
                attachtest = re.search(settings.ATTACHMENT, callnum)
 
                 if loc == RESERVES_DESK_NAME:
-                    desk += anystatus_here
+                   desk += anystatus_here
                     avail += avail_here
+                   dueinfo = ''
+                               
                     if (voltest and vol > 0): 
                        if (int(voltest.group(1)) > vol):
                                callsuffix = "/" + callnum
                        else:
                                callprefix = callnum + "/" 
-                   elif attachtest and callno.find(attachtest.group(0)) == -1:
+                    elif attachtest and callno.find(attachtest.group(0)) == -1:
                        if len(callno) > 0:
                                callsuffix = "/" + callnum
                        else:
                                callprefix = callnum
-                   else:
-                       callno = callnum
-                   dueinfo = ''
-                lib += anystatus_here
-               copyids = E1(settings.OPENSRF_CN_CALL, bib_id, callnum, org)
+                    else:
+                       callno = callnum
+                
+                    lib += anystatus_here
+                    copyids = E1(settings.OPENSRF_CN_CALL, bib_id, callnum, org)
                
-               """
-               we want to return the resource that will be returned first if
-               already checked out
-               """
-               for copyid in copyids:
+               
+                    """
+                    we want to return the resource that will be returned first if
+                    already checked out
+                    """
+                    for copyid in copyids:
                        circinfo = E1(settings.OPENSRF_FLESHED2_CALL, copyid)
-                       if loc == RESERVES_DESK_NAME: 
+
+                       thisloc = circinfo.get("location")
+                       if thisloc:
+                               thisloc = thisloc.get("name")
+               
+                       if thisloc == RESERVES_DESK_NAME: 
                                bringfw = attachtest
+
                                # multiple volumes
                                if voltest and callno.find(voltest.group(0)) == -1:
                                        bringfw = True
@@ -170,7 +181,7 @@ def _item_status(bib_id):
                                                                        tmpinfo = dueinfo
                                                                        dueinfo = voltest.group(0) + ': ' + time.strftime(settings.DUE_FORMAT,earliestdue) 
                                                                        if len(tmpinfo) > 0:
-                                                                               dueinfo = dueinfo + "/" + dueinfo
+                                                                               dueinfo = dueinfo + "/" + tmpinfo
                                                                callprefix = callsuffix = ''
                                                        elif attachtest:
                                                                tmpinfo = dueinfo
@@ -181,7 +192,7 @@ def _item_status(bib_id):
                                                                else:
                                                                        callno = callnum
                                                                if len(tmpinfo) > 0:
-                                                                       dueinfo = dueinfo + "/" + dueinfo
+                                                                       dueinfo = dueinfo + "/" + tmpinfo
                                                                
                                                        if not bringfw:
                                                                dueinfo = time.strftime(settings.DUE_FORMAT,earliestdue)
@@ -192,12 +203,20 @@ def _item_status(bib_id):
                                                        earliestdue = duetime
                                                        dueinfo = time.strftime(DUE_FORMAT,earliestdue)
                                                        callno = callnum
-                                       
-               if voltest or attachtest:
-                       callno = callprefix + callno + callsuffix
-               if voltest:
-                       vol = int(voltest.group(1))
-            return (lib, desk, avail, callno, dueinfo, circmod)
+
+                               alldisplay = callnum + ' Available'
+                               if (avail == 0):
+                                       alldisplay = '%s %s' % (callnum, dueinfo)
+                               alldues.append(alldisplay)
+                       
+                       if voltest or attachtest:
+                               if callno.find(callprefix) == -1:
+                                       callno = callprefix + callno 
+                               if callno.find(callsuffix) == -1:
+                                       callno = callno + callsuffix
+                       if voltest:
+                               vol = int(voltest.group(1))
+            return (lib, desk, avail, callno, dueinfo, circmod, alldues)
        except:
            print "due date/call problem: ", bib_id
             print "*** print_exc:"
index e8cd4e0..62aa646 100644 (file)
@@ -764,7 +764,7 @@ class Item(BaseModel):
         if not stat:
             return (False, 'Status information not available.')
         else:
-            lib, desk, avail, callno, dueinfo, circmod = stat
+            lib, desk, avail, callno, dueinfo, circmod, alldues = stat
             return (avail > 0,
                     '%d of %d copies available at reserves desk; '
                     '%d total copies in library system'
index 08464b0..d4ac24a 100644 (file)
@@ -40,7 +40,7 @@ searchtext = _('search this site...')
       ?>
       <div class="availability" py:if="item.item_type == 'PHYS'">
        <a href="${item.item_url()}">
-       <div py:if="valid" py:with="(_lib, _desk, _avail, _callno, _dueinfo, _circmod) = stat"
+       <div py:if="valid" py:with="(_lib, _desk, _avail, _callno, _dueinfo, _circmod, _alldues) = stat"
             class="${_avail &gt; 0 and 'available' or 'unavailable'}"
             title="${_avail} of ${_desk} copies available at reserves desk; ${_lib} total copies in library system">
           <div>${_avail and 'Available' or 'Unavailable'} (${_avail}/${_desk})</div>
@@ -68,11 +68,30 @@ searchtext = _('search this site...')
          </div>
                
          </a>
-         <div py:if="valid"  py:with="(_lib, _desk, _avail, _callno, _dueinfo, _circmod) = stat">
-               <div py:if="_desk &gt; 1 and item.bib_id and gethook('bib_id_to_url')"
-                       py:with="url=callhook('bib_id_to_url', item.bib_id)">
-                       <a py:if="url" href="${url}">View status of all copies in catalogue</a>
-               </div>
+         <div py:if="valid"  py:with="(_lib, _desk, _avail, _callno, _dueinfo, _circmod, _alldues) = stat">
+               <div id="status_${item.id}" style="display: none;"> 
+               <script type="text/javascript">
+                       function show_stuff(the_id){
+                               document.getElementById('status_' + the_id).style.display="block";
+                               document.getElementById('showlink_' + the_id).style.display="none";
+                               document.getElementById('hidelink_' + the_id).style.display="block";
+                       }
+                       function hide_stuff(the_id){
+                               document.getElementById('status_' + the_id).style.display="none";
+                               document.getElementById('showlink_' + the_id).style.display="block";
+                               document.getElementById('hidelink_' + the_id).style.display="none";
+                       }
+               </script>
+               <div py:for="k in _alldues">
+                       ${k}
+               </div>
+               </div>
+               <div id="showlink_${item.id}" py:if="len(_alldues) > 1">
+                       <a href="javascript:show_stuff('${item.id}');">Show status of all copies</a>
+               </div>
+               <div style="display: none;" id="hidelink_${item.id}" py:if="len(_alldues) > 1">
+                       <a href="javascript:hide_stuff('${item.id}');">Hide status details</a>
+               </div>
          </div>
       </div>