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
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.")
__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:
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.
+ """
-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):
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
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"
<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">