move the declaration text into the customization system. Fixed bug in hooksystem.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sat, 13 Nov 2010 01:42:55 +0000 (01:42 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sat, 13 Nov 2010 01:42:55 +0000 (01:42 +0000)
The bug is that the getattr() calls should have had a default third argument
of None, so that if the lookup failed, None would be the result. Instead, we
got AttributeErrors when no such hook existed: not what I intended.

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

conifer/integration/uwindsor.py
conifer/plumbing/hooksystem.py
conifer/syrup/integration.py
conifer/syrup/views/items.py
conifer/templates/item/item_metadata.xhtml

index 230ed96..3b882f1 100644 (file)
@@ -211,3 +211,17 @@ def proxify_url(url):
     the proxy. If not, return None.
     """
     return ezproxy_service.proxify(url)
+
+
+def download_declaration():
+    """
+    Returns a string. The declaration to which students must agree when
+    downloading electronic documents. If not customized, a generic message
+    will be used.
+    """
+    return ("I warrant that I am a student of the University of Windsor "
+            "registered in the aforementioned course. By pressing the "
+            "'Request' button below, I am requesting a digital copy of a "
+            "reading (chapter, article) for my own private study and "
+            "research use. I agree that I will not reproduce, redistribute "
+            "or transmit a copy of the reading in any format.")
index 935b592..e90e52c 100644 (file)
@@ -6,15 +6,15 @@ import conifer.syrup.integration as HOOKS
 __all__ = ['callhook', 'callhook_required', 'gethook']
 
 def gethook(name, default=None):
-    return getattr(HOOKS, name) or default
+    return getattr(HOOKS, name, None) or default
 
 def callhook_required(name, *args, **kwargs):
-    f = getattr(HOOKS, name)
+    f = getattr(HOOKS, name, None)
     assert f, 'implementation for hook %r required but not found' % name
     return f(*args, **kwargs)
 
 def callhook(name, *args, **kwargs):
-    f = getattr(HOOKS, name)
+    f = getattr(HOOKS, name, None)
     if f:
         return f(*args, **kwargs)
     else:
index b55f512..db75ea0 100644 (file)
@@ -129,4 +129,10 @@ def proxify_url(url):
     the proxy. If not, return None.
     """
 
-                  
+@disable
+def download_declaration():
+    """
+    Returns a string. The declaration to which students must agree when
+    downloading electronic documents. If not customized, a generic message
+    will be used.
+    """
index 1e7fb5c..f7a7e3f 100644 (file)
@@ -1,6 +1,7 @@
-from _common       import *
-from conifer.syrup import integration
-from xml.etree     import ElementTree as ET
+from _common                     import *
+from conifer.plumbing.hooksystem import *
+from conifer.syrup               import integration
+from xml.etree                   import ElementTree as ET
 
 @members_only
 def item_detail(request, site_id, item_id):
@@ -23,8 +24,10 @@ def item_metadata(request, site_id, item_id):
         return _heading_detail(request, item)
     else:
         item_declaration_required = item.needs_declaration_from(request.user)
+        custom_declaration = callhook('download_declaration')
         return g.render('item/item_metadata.xhtml', site=item.site,
                         item_declaration_required=item_declaration_required,
+                        custom_declaration=custom_declaration,
                         item=item)
 
 @members_only
index 666ce5b..16cdd62 100644 (file)
@@ -4,6 +4,7 @@ site_title = '%s: %s (%s)' % (site.course.code, site.course.name, site.term)
 hier = item.hierarchy()[:-1]
 title = item.title
 is_editor = site.can_edit(request.user)
+item_declaration_required = True #fixme
 ?>
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:xi="http://www.w3.org/2001/XInclude"
@@ -55,7 +56,12 @@ is_editor = site.can_edit(request.user)
     <div py:if="item.item_type=='ELEC'">
       <h2 class="metadata_subhead">Download the document</h2>
       <div id="ask_to_download_panel">
-       <p>I warrant that I am a student of the University of Windsor registered in the aforementioned course. By pressing the 'Request' button below, I am requesting a digital copy of a reading (chapter, article) for my own private study and research use. I agree that I will not reproduce, redistribute or transmit a copy of the reading in any format.</p>
+       <p py:if="custom_declaration" py:content="custom_declaration"/>
+       <p py:if="not custom_declaration">By pressing the 'Request' button
+       below, I am requesting a digital copy of a reading (chapter, article)
+       for my own private study and research use. I agree that I will not
+       reproduce, redistribute or transmit a copy of the reading in any
+       format.</p>
        <p><a class="bigdownload" href="javascript:askToDownload();"><button>Request to download this document</button></a></p>
       </div>
       <div id="downloadpanel">