physical item view: check and display item-status
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 5 Apr 2009 19:18:07 +0000 (19:18 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 5 Apr 2009 19:18:07 +0000 (19:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@277 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/TODO
conifer/custom/lib_integration.py
conifer/static/main.css
conifer/syrup/models.py
conifer/syrup/views.py
conifer/templates/item_add_cat_search.xhtml
conifer/templates/item_metadata.xhtml

index 1a4a07e..d61f768 100644 (file)
@@ -2,6 +2,9 @@ CRITICAL:
 
 IMPORTANT:
 
+* finish the physical-item received workflow.
+  * how to model 'received' in the database?
+
 * does 'move to new heading' show up in the right places? Should be like 'edit'.
 
 * a short-number for physical items. Sort of a barcode, but intended
index 4c155c7..3b0c218 100644 (file)
@@ -41,10 +41,12 @@ from conifer.libsystems.z3950 import yaz_search
 from conifer.libsystems.z3950.marcxml import marcxml_to_dictionary
 
 
+@caching('itemstatus', timeout=300)
 @SIP
 def patron_info(conn, barcode):
     return conn.patron_info(barcode)
 
+@caching('itemstatus', timeout=300)
 @SIP
 def item_status(conn, barcode):
     return conn.item_info(barcode)
index 32f787c..1ac2339 100644 (file)
@@ -54,7 +54,7 @@ tbody td, tbody th { vertical-align: top; }
 /* heading sizes and colours. */
 
 h1 { font-size: 150%;  }
-h2 { font-size: 135%; }
+h2 { font-size: 125%; }
 h3 { font-size: 120%; }
 
 h1 { color: navy; }
@@ -226,7 +226,8 @@ p.todo, div.todo { background-color: #fdd; padding: 6; margin: 12; border-left:
 { float: right; font-size: 95%; margin: 8 0; clear: both; text-align: right; }
 
 
-.breadcrumbs { margin: 8 8 8 0; }
+.breadcrumbs { margin: 8 8 8 0; width: 800; 
+            text-indent: -24; padding-left: 24; }
 
 .errorlist { float: right; }
 .errorlist li { color: red; font-size: 90%; }
@@ -273,3 +274,4 @@ li.sort_item:hover { background-color: #eee; }
 ul.heading_tree li  { list-style: none; }
 ul.heading_tree { margin: 0; padding-left: 0; }
 ul.heading_tree ul { margin: 0; padding-left: 25; }
+
index ade38fa..03eb491 100644 (file)
@@ -7,6 +7,7 @@ from genshi import Markup
 from django.utils.translation import ugettext as _
 from conifer.custom import course_codes # fixme, not sure if conifer.custom is a good parent.
 from conifer.custom import course_sections # fixme, not sure if conifer.custom is a good parent.
+from conifer.custom import lib_integration
 import re
 import random
 
@@ -461,7 +462,19 @@ class Item(m.Model):
         else:
             return self.course.course_url()
 
-
+    def describe_physical_item_status(self):
+        """Return a (bool,str) tuple: whether the item is available,
+        and a friendly description of the physical item's status"""
+        if self.item_type != 'PHYS':
+            return False, _('(Not a physical item)')
+        
+        #fixme: just having barcode in item-metadata doesn't mean 'in Reserves'
+        bc = self.barcode()
+        if not bc:
+            return False, _('On order')
+        else:
+            status = lib_integration.item_status(bc)
+            return status['available'], _(status['status'])
 
 metadata_attributes = {
     'dc:contributor': _('Contributor'),
index 0b77000..133311c 100644 (file)
@@ -710,8 +710,20 @@ def item_add(request, course_id, item_id):
 
 @instructors_only
 def item_add_cat_search(request, course_id, item_id):
+    # this chunk stolen from item_add(). Refactor.
+    parent_item_id = item_id
+    if parent_item_id=='0':
+        parent_item = None
+        course = get_object_or_404(models.Course, pk=course_id)
+    else:
+        parent_item = get_object_or_404(models.Item, pk=parent_item_id, course__id=course_id)
+        assert parent_item.item_type == 'HEADING', _('You can only add items to headings!')
+        course = parent_item.course
+    #----------
+
     if request.method != 'POST':
-        return g.render('item_add_cat_search.xhtml', results=[], query='')
+        return g.render('item_add_cat_search.xhtml', results=[], query='', 
+                        course=course, parent_item=parent_item)
 
     # POST handler
     query     = request.POST.get('query','').strip()
@@ -721,7 +733,8 @@ def item_add_cat_search(request, course_id, item_id):
         assert query, 'must provide a query.'
         results = lib_integration.cat_search(query)
         return g.render('item_add_cat_search.xhtml', 
-                        results=results, query=query)
+                        results=results, query=query, 
+                        course=course, parent_item=parent_item)
     else:
         # User has selected an item; add it to course site.
         #fixme, this block copied from item_add. refactor.
index ed6f011..b41f1fe 100644 (file)
@@ -9,6 +9,7 @@ dc_keys = ['dc:title', 'dc:creator', 'dc:publisher', 'dc:date']
       xmlns:py="http://genshi.edgewall.org/">
 <xi:include href="master.xhtml"/>
 <xi:include href="paginate.xhtml"/>
+<xi:include href="components/course.xhtml"/>
 <head>
   <title>${title}</title>
   <script type="text/javascript">
@@ -20,7 +21,9 @@ dc_keys = ['dc:title', 'dc:creator', 'dc:publisher', 'dc:date']
   </script>
 </head>
 <body>
-    <h1>${title}</h1>
+    ${course_banner(course)}
+    ${nested_title(parent_item)}
+    <h2>${title}</h2>
     <form method="POST" action=".">
       <input type="text" id="query" name="query" value="${query}" 
             style="font-size: larger; width: 600;"/>
index 9ce7f75..7121660 100644 (file)
@@ -13,6 +13,10 @@ is_editor = course.can_edit(request.user)
   <xi:include href="components/course.xhtml"/>
   <head>
     <title>${title}</title>
+    <style>
+      .available   { color: green; border-left: 16px green solid; padding-left: 8px; }
+      .unavailable { color: red; border-left: 16px red solid; padding-left: 8px; }
+    </style>
   </head>
   <body>
     ${course_banner(course)}
@@ -28,18 +32,22 @@ is_editor = course.can_edit(request.user)
     <table class="metadata_table" style="margin-top: 1em;">
       <tr><th>Title</th><td>${item.title}</td></tr>
       <tr><th>Type</th><td>${item.get_item_type_display()}</td></tr>
+      <tr py:if="item.item_type=='PHYS'"
+         py:with="avail, status = item.describe_physical_item_status()">
+       <th>Status</th><td><div class="${avail and 'available' or 'unavailable'}">${status}</div></td>
+      </tr>
       <tr py:if="item.url"><th>URL</th><td><a href="${item.url}">${item.url}</a></td></tr>
     </table>
     <div py:if="item.item_type=='ELEC'">
-    <h2 class="metadata_subhead">Attached document</h2>
-    <table class="metadata_table">
-    <tr><th>Content type</th><td>${item.fileobj_mimetype}</td></tr>
-    <tr><th>Size</th><td>${item.fileobj.size} bytes</td></tr>
-    <tr><th/><td><a class="bigdownload" href="${item.item_url()}">Download</a></td></tr>
-    </table>
+      <h2 class="metadata_subhead">Attached document</h2>
+      <table class="metadata_table">
+       <tr><th>Content type</th><td>${item.fileobj_mimetype}</td></tr>
+       <tr><th>Size</th><td>${item.fileobj.size} bytes</td></tr>
+       <tr><th/><td><a class="bigdownload" href="${item.item_url()}">Download</a></td></tr>
+      </table>
     </div>
     <div py:if="metadata">
-      <h2 class="metadata_subhead">Additional metadata</h2>
+      <h3>Additional metadata</h3>
       <table class="metadata_table">
        <tr py:for="attr in metadata">
          <th>${attr.get_name_display()}</th>