[open-ils-commits] r1066 - in servres/trunk/conifer: integration plumbing syrup syrup/views templates/item (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Nov 12 20:42:57 EST 2010
Author: gfawcett
Date: 2010-11-12 20:42:55 -0500 (Fri, 12 Nov 2010)
New Revision: 1066
Modified:
servres/trunk/conifer/integration/uwindsor.py
servres/trunk/conifer/plumbing/hooksystem.py
servres/trunk/conifer/syrup/integration.py
servres/trunk/conifer/syrup/views/items.py
servres/trunk/conifer/templates/item/item_metadata.xhtml
Log:
move the declaration text into the customization system. Fixed bug in hooksystem.
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.
Modified: servres/trunk/conifer/integration/uwindsor.py
===================================================================
--- servres/trunk/conifer/integration/uwindsor.py 2010-11-13 01:39:14 UTC (rev 1065)
+++ servres/trunk/conifer/integration/uwindsor.py 2010-11-13 01:42:55 UTC (rev 1066)
@@ -211,3 +211,17 @@
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.")
Modified: servres/trunk/conifer/plumbing/hooksystem.py
===================================================================
--- servres/trunk/conifer/plumbing/hooksystem.py 2010-11-13 01:39:14 UTC (rev 1065)
+++ servres/trunk/conifer/plumbing/hooksystem.py 2010-11-13 01:42:55 UTC (rev 1066)
@@ -6,15 +6,15 @@
__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:
Modified: servres/trunk/conifer/syrup/integration.py
===================================================================
--- servres/trunk/conifer/syrup/integration.py 2010-11-13 01:39:14 UTC (rev 1065)
+++ servres/trunk/conifer/syrup/integration.py 2010-11-13 01:42:55 UTC (rev 1066)
@@ -129,4 +129,10 @@
the proxy. If not, return None.
"""
-
+ at 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.
+ """
Modified: servres/trunk/conifer/syrup/views/items.py
===================================================================
--- servres/trunk/conifer/syrup/views/items.py 2010-11-13 01:39:14 UTC (rev 1065)
+++ servres/trunk/conifer/syrup/views/items.py 2010-11-13 01:42:55 UTC (rev 1066)
@@ -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 @@
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
Modified: servres/trunk/conifer/templates/item/item_metadata.xhtml
===================================================================
--- servres/trunk/conifer/templates/item/item_metadata.xhtml 2010-11-13 01:39:14 UTC (rev 1065)
+++ servres/trunk/conifer/templates/item/item_metadata.xhtml 2010-11-13 01:42:55 UTC (rev 1066)
@@ -4,6 +4,7 @@
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 @@
<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">
More information about the open-ils-commits
mailing list