[open-ils-commits] r1131 - in servres/trunk/conifer: static syrup syrup/views templates templates/components templates/item (gfawcett)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Dec 28 13:05:06 EST 2010


Author: gfawcett
Date: 2010-12-28 13:05:03 -0500 (Tue, 28 Dec 2010)
New Revision: 1131

Modified:
   servres/trunk/conifer/static/main.css
   servres/trunk/conifer/syrup/models.py
   servres/trunk/conifer/syrup/views/items.py
   servres/trunk/conifer/templates/components/site.xhtml
   servres/trunk/conifer/templates/item/item_add_elec.xhtml
   servres/trunk/conifer/templates/item/item_heading_detail.xhtml
   servres/trunk/conifer/templates/item/item_metadata.xhtml
   servres/trunk/conifer/templates/site_detail.xhtml
Log:
copyright status enhancements

Now, electronic items that are not cleared for copyright are not downloadable
by students. Such items are visible to instructors and staff, with a clear
visual warning.

Modified: servres/trunk/conifer/static/main.css
===================================================================
--- servres/trunk/conifer/static/main.css	2010-12-28 17:29:34 UTC (rev 1130)
+++ servres/trunk/conifer/static/main.css	2010-12-28 18:05:03 UTC (rev 1131)
@@ -185,6 +185,7 @@
 .itemtree li .mainline { padding-left: 8px; }
 
 .itemtree li .author_pub { padding-left: 8px; font-size: 90%; margin: 2px 0; color: #111; }
+.itemtree li .forbidden_notice { padding-left: 8px; font-size: 90%; margin: 2px 0; color: darkred; }
 
 .itemtree .metalink { padding-left: 8px; color: gray; }
 .itemtree .metalink a {
@@ -243,6 +244,9 @@
     list-style-image: url(tango/x-office-address-book.png);
 }
 
+.itemtree li.forbidden {
+    background-color: #fdd;
+}
 
 .instructors {
   border: 1px solid #ccc;

Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py	2010-12-28 17:29:34 UTC (rev 1130)
+++ servres/trunk/conifer/syrup/models.py	2010-12-28 18:05:03 UTC (rev 1131)
@@ -691,6 +691,9 @@
         """Should an 'About' link be displayed for this item?"""
         return self.item_type in ('URL',)
 
+    def copyright_status_ok(self):
+        return not (self.item_type == u'ELEC' and self.copyright_status == u'UK')
+
     def item_download_url(self):
         if self.item_type != 'ELEC':
             return None

Modified: servres/trunk/conifer/syrup/views/items.py
===================================================================
--- servres/trunk/conifer/syrup/views/items.py	2010-12-28 17:29:34 UTC (rev 1130)
+++ servres/trunk/conifer/syrup/views/items.py	2010-12-28 18:05:03 UTC (rev 1131)
@@ -292,6 +292,16 @@
     site = get_object_or_404(models.Site, pk=site_id)
     item = get_object_or_404(models.Item, pk=item_id, site__id=site_id)
     assert item.item_type == 'ELEC', _('Can only download ELEC documents!')
+
+    # don't allow download of items that need a declaration.
+    item_declaration_required = item.needs_declaration_from(request.user)
+    if item_declaration_required:
+        return HttpResponseRedirect(item.item_url())
+
+    # don't allow download of items that are not copyright-cleared.
+    if not (item.copyright_status_ok() or site.can_edit(request.user)):
+        return HttpResponseRedirect(item.item_url())
+
     fileiter = item.fileobj.chunks()
     resp = HttpResponse(fileiter)
     resp['Content-Type'] = item.fileobj_mimetype or 'application/octet-stream'

Modified: servres/trunk/conifer/templates/components/site.xhtml
===================================================================
--- servres/trunk/conifer/templates/components/site.xhtml	2010-12-28 17:29:34 UTC (rev 1130)
+++ servres/trunk/conifer/templates/components/site.xhtml	2010-12-28 18:05:03 UTC (rev 1131)
@@ -30,7 +30,7 @@
   <ul py:def="show_tree(tree, edit=False)"
       py:if="tree"
       class="itemtree">
-    <li py:for="item, subs in tree" class="item_${item.item_type} an_item"
+    <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="item.marcxml" class="unapi-id" title="${item.id}"/>
       <div class="availability" py:if="item.item_type == 'PHYS'">
@@ -57,6 +57,7 @@
 		<span py:if="item.publisher">${item.publisher}.</span>
 		<span py:if="item.published">${item.published}.</span>
       </div>
+      <div class="forbidden_notice" py:if="forbidden">Awaiting copyright clearance: Not available to students.</div>
 	  <div>
 		<div class="menublock" py:if="not (item.item_type=='HEADING' and not edit)">
 		  <span py:if="item.needs_meta_link()">

Modified: servres/trunk/conifer/templates/item/item_add_elec.xhtml
===================================================================
--- servres/trunk/conifer/templates/item/item_add_elec.xhtml	2010-12-28 17:29:34 UTC (rev 1130)
+++ servres/trunk/conifer/templates/item/item_add_elec.xhtml	2010-12-28 18:05:03 UTC (rev 1131)
@@ -38,12 +38,13 @@
       <tr><th>Issue</th><td><input type="text" name="issue" value="${item.issue}"/></td></tr>
       <tr><th>Pages</th><td><input type="text" name="pages" value="${item.pages}"/></td></tr>
       <tr><th>ISBN</th><td><input type="text" name="isbn" value="${item.isbn}"/></td></tr>
-      <tr>
+      <tr py:if="user.is_staff">
 	<th>Copyright Status</th>
 	<td>
 	  <select name="copyright_status">
 	    <option py:for="k,v in item.COPYRIGHT_STATUS_CHOICES"
 		    py:attrs="{'selected': item.copyright_status==k or None}"
+		    value="${k}"
 		    py:content="v"/>
 	  </select>
 	</td>

Modified: servres/trunk/conifer/templates/item/item_heading_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/item/item_heading_detail.xhtml	2010-12-28 17:29:34 UTC (rev 1130)
+++ servres/trunk/conifer/templates/item/item_heading_detail.xhtml	2010-12-28 18:05:03 UTC (rev 1131)
@@ -12,6 +12,7 @@
   <xi:include href="../components/site.xhtml"/>
    <head>
     <title>${title}</title>
+    <style py:if="not is_editor">.forbidden { display: none; }</style>
   </head>
   <body>
     ${site_banner(site)}

Modified: servres/trunk/conifer/templates/item/item_metadata.xhtml
===================================================================
--- servres/trunk/conifer/templates/item/item_metadata.xhtml	2010-12-28 17:29:34 UTC (rev 1130)
+++ servres/trunk/conifer/templates/item/item_metadata.xhtml	2010-12-28 18:05:03 UTC (rev 1131)
@@ -60,6 +60,9 @@
 
     <div py:if="item.item_type=='ELEC'">
       <h2 class="metadata_subhead">Download the document</h2>
+      <div class="errors" py:if="not item.copyright_status_ok()">
+	Note: this item is awaiting <a href="edit/">copyright clearance</a>. Only staff and instructors may download it.
+      </div>
       <div id="ask_to_download_panel">
 	<p py:if="custom_declaration" py:content="custom_declaration"/>
 	<p py:if="not custom_declaration">By pressing the 'Request' button

Modified: servres/trunk/conifer/templates/site_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/site_detail.xhtml	2010-12-28 17:29:34 UTC (rev 1130)
+++ servres/trunk/conifer/templates/site_detail.xhtml	2010-12-28 18:05:03 UTC (rev 1131)
@@ -11,6 +11,7 @@
   <xi:include href="components/site.xhtml"/>
   <head>
     <title>${title}</title>
+    <style py:if="not is_editor">.forbidden { display: none; }</style>
   </head>
   <body>
     ${site_banner(site)}



More information about the open-ils-commits mailing list