copyright status enhancements
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 28 Dec 2010 18:05:03 +0000 (18:05 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 28 Dec 2010 18:05:03 +0000 (18:05 +0000)
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.

git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1131 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/static/main.css
conifer/syrup/models.py
conifer/syrup/views/items.py
conifer/templates/components/site.xhtml
conifer/templates/item/item_add_elec.xhtml
conifer/templates/item/item_heading_detail.xhtml
conifer/templates/item/item_metadata.xhtml
conifer/templates/site_detail.xhtml

index 9fc8a37..964509c 100644 (file)
@@ -185,6 +185,7 @@ span.final_item { font-weight: bold; font-size: 110%; }
 .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 @@ li.item_HEADING  .headingmainline a.mainlink:hover {
     list-style-image: url(tango/x-office-address-book.png);
 }
 
+.itemtree li.forbidden {
+    background-color: #fdd;
+}
 
 .instructors {
   border: 1px solid #ccc;
index 6752b57..43eeb17 100644 (file)
@@ -691,6 +691,9 @@ class Item(BaseModel):
         """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
index 6bb347e..4e4ffdd 100644 (file)
@@ -292,6 +292,16 @@ def item_download(request, site_id, item_id, filename):
     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'
index 47fe28e..64a94dd 100644 (file)
@@ -30,7 +30,7 @@ searchtext = _('search this site...')
   <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 @@ searchtext = _('search this site...')
                <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()">
index 66cd8c4..eae71c5 100644 (file)
@@ -38,12 +38,13 @@ if len(authors) < 2:
       <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>
index 553de59..d8d0cd6 100644 (file)
@@ -12,6 +12,7 @@ item_tree = site.item_tree(subtree=item)
   <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)}
index 005f228..bda6bf7 100644 (file)
@@ -60,6 +60,9 @@ is_editor = site.can_edit(request.user)
 
     <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
index 1a26046..0573436 100644 (file)
@@ -11,6 +11,7 @@ is_joinable = site.is_joinable_by(request.user)
   <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)}