[open-ils-commits] r1225 - in servres/trunk/conifer: integration syrup templates/components (artunit)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Feb 9 00:23:28 EST 2011


Author: artunit
Date: 2011-02-09 00:23:25 -0500 (Wed, 09 Feb 2011)
New Revision: 1225

Modified:
   servres/trunk/conifer/integration/uwindsor.py
   servres/trunk/conifer/syrup/models.py
   servres/trunk/conifer/templates/components/site.xhtml
Log:
embed status information for all copies

Modified: servres/trunk/conifer/integration/uwindsor.py
===================================================================
--- servres/trunk/conifer/integration/uwindsor.py	2011-02-09 00:29:44 UTC (rev 1224)
+++ servres/trunk/conifer/integration/uwindsor.py	2011-02-09 05:23:25 UTC (rev 1225)
@@ -99,6 +99,8 @@
 	    dueinfo = ''
             callno = ''
             circmod = ''
+            alldues = []
+
             for org, callnum, loc, stats in counts:
 		callprefix = ''
 		callsuffix = ''
@@ -119,32 +121,41 @@
 		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 @@
 									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 @@
 								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 @@
 							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:"

Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py	2011-02-09 00:29:44 UTC (rev 1224)
+++ servres/trunk/conifer/syrup/models.py	2011-02-09 05:23:25 UTC (rev 1225)
@@ -764,7 +764,7 @@
         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'

Modified: servres/trunk/conifer/templates/components/site.xhtml
===================================================================
--- servres/trunk/conifer/templates/components/site.xhtml	2011-02-09 00:29:44 UTC (rev 1224)
+++ servres/trunk/conifer/templates/components/site.xhtml	2011-02-09 05:23:25 UTC (rev 1225)
@@ -40,7 +40,7 @@
       ?>
       <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 @@
          </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>
          



More information about the open-ils-commits mailing list