show call number on index and metadata pages; better item-availability presentation.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Thu, 6 Jan 2011 03:00:58 +0000 (03:00 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Thu, 6 Jan 2011 03:00:58 +0000 (03:00 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1164 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/TODO
conifer/static/main.css
conifer/syrup/models.py
conifer/templates/components/site.xhtml
conifer/templates/item/item_metadata.xhtml

index 3560aa3..a0d1fea 100644 (file)
@@ -2,14 +2,11 @@ NEW:
 
 * add/remove individuals in course sites
 
-* make "DVD" and other media types obvious (icons, explicit descriptions, etc.)
-
 * bookbag-URL search should import all items from the bookbag (if they don't already exist)
+  -- actually, I'm not 100% certain about this, esp if we implement "Sakai linkup" below.
 
 * Sakai linkup -- test, seems not to work on SHOWCASE
 
-* show call number (852c) on index pages
-
 * index pages when printed, should show call all numbers clearly
 
 * search should include course number (fragments too, not just full course codes)
@@ -113,3 +110,7 @@ RECENTLY DONE:
 
 * make sure volume, issue, source title, etc. are exposed over unAPI.
 
+* make "DVD" and other media types obvious (icons, explicit descriptions, etc.)
+
+* show call number on index pages
+
index 06a831c..4711255 100644 (file)
@@ -356,6 +356,14 @@ ul.heading_tree { margin: 0; padding-left: 0; }
 ul.heading_tree ul { margin: 0; padding-left: 25px; }
 
 
-.availability { float: right; color: darkred; background-color: #eee; padding: 4px; min-width: 24px; }
-.availability .available { color: green; }
-.avail_nonphys { background-color: white; }
\ No newline at end of file
+.availability {
+    float: right; color: darkred; background-color: #eee; 
+    width: 150px; margin-left: 8px; 
+    font-size: 90%;
+}
+.availability div { padding: 2px 4px; }
+.availability a { text-decoration: none; }
+.availability .available { color: darkgreen; background-color: #ded; }
+.availability .unavailable { color: darkred; background-color: #edd; }
+.avail_nonphys { background-color: white; }
+.availability .callnumber { margin: 2px 0; }
index 076783c..cc45f6e 100644 (file)
@@ -659,8 +659,18 @@ class Item(BaseModel):
 
     #--------------------------------------------------
     # MARC
+
+    _marc_dict_cache = None
+
     def marc_as_dict(self):
-        return MX.record_to_dictionary(self.marcxml)
+        # cache a copy of the dict expansion, since it's semi-expensive to
+        # generate, and is sometimes used more than once on the same page.
+        if self._marc_dict_cache is None:
+            if not self.marcxml:
+                self._marc_dict_cache = {}
+            else:
+                self._marc_dict_cache = MX.record_to_dictionary(self.marcxml)
+        return self._marc_dict_cache
 
     def marc_dc_subset(self):
         return json.dumps(self.marc_as_dict())
@@ -750,6 +760,7 @@ class Item(BaseModel):
                     'f':'videocassette',
                     'r':'videoreel',
                     'z':'video, other format'}
+
     def video_type(self):
         if not self.marcxml:
             return None
@@ -758,6 +769,18 @@ class Item(BaseModel):
             vtype = m.group(1)
             return self._video_types.get(vtype, 'video, unknown format')
 
+    def call_number(self):
+        dct = self.marc_as_dict()
+        if dct:
+            try:
+                if '090a' in dct:   # for films. FIXME, is this legit?
+                    return dct['090a']
+                cn = ('%s %s' % (dct.get('050a', ''), 
+                                 dct.get('050b', ''))).strip()
+                return cn
+            except:
+                return None
+
     # TODO: stuff I'm not sure about yet. I don't think it belongs here.
 
     def title_hl(self, terms):
index bc142f0..1481f50 100644 (file)
@@ -33,16 +33,19 @@ searchtext = _('search this site...')
     <li py:for="item, subs in tree" py:with="forbidden=not item.copyright_status_ok()" class="item_${item.item_type} an_item ${forbidden and 'forbidden' or ''}"
        id="item_${item.id}">
       <abbr py:if="not item.item_type=='HEADING'" class="unapi-id" title="${item.id}"/>
+      <?python
+       stat = callhook('item_status', item) if (item.item_type == 'PHYS') else None
+       valid = stat is not None
+      ?>
       <div class="availability" py:if="item.item_type == 'PHYS'">
-       <?python
-         stat = callhook('item_status', item) if (item.item_type == 'PHYS') else None
-         valid = stat is not None
-       ?>
+       <a href="${item.item_url()}">
        <div py:if="valid" py:with="(_lib, _desk, _avail) = stat"
             class="${_avail &gt; 0 and 'available' or 'unavailable'}"
             title="${_avail} of ${_desk} copies available at reserves desk; ${_lib} total copies in library system">
-         ${_avail}/${_desk}
+         <div>${_avail and 'Available' or 'Unavailable'} (${_avail}/${_desk})</div>
+         <div class="callnumber">${item.call_number()}</div>
        </div>
+       </a>
        <div py:if="not valid" title="No copies are available at the reserves desk. No further status information is available.">
          &#x2205;
        </div>
index 6a56a84..afe53c7 100644 (file)
@@ -5,6 +5,7 @@ hier = item.hierarchy()[:-1]
 title = item.title
 is_editor = site.can_edit(request.user)
 vidtype = item.video_type()
+callnum = item.call_number()
 ?>
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:xi="http://www.w3.org/2001/XInclude"
@@ -51,6 +52,7 @@ vidtype = item.video_type()
       <tr py:if="item.issue"><th>Issue</th><td>${item.issue}</td></tr>
       <tr py:if="item.pages"><th>Pages</th><td>${item.pages}</td></tr>
       <tr py:if="item.isbn"><th>ISBN</th><td>${item.isbn}</td></tr>
+      <tr py:if="callnum"><th>Call Number</th><td>${callnum}</td></tr>
       <tr py:if="item.item_type=='ELEC'"><th>Copyright status</th><td>${item.get_copyright_status_display()}</td></tr>
       <tr><th>Type</th><td>${item.get_item_type_display()}</td></tr>
       <tr py:if="item.item_type=='PHYS'"