From 466f420bc74bd05f62dccfd8b292e65919087995 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Sat, 13 Nov 2010 01:42:55 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1066 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/integration/uwindsor.py | 14 ++++++++++++++ conifer/plumbing/hooksystem.py | 6 +++--- conifer/syrup/integration.py | 8 +++++++- conifer/syrup/views/items.py | 9 ++++++--- conifer/templates/item/item_metadata.xhtml | 8 +++++++- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/conifer/integration/uwindsor.py b/conifer/integration/uwindsor.py index 230ed96..3b882f1 100644 --- a/conifer/integration/uwindsor.py +++ b/conifer/integration/uwindsor.py @@ -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.") diff --git a/conifer/plumbing/hooksystem.py b/conifer/plumbing/hooksystem.py index 935b592..e90e52c 100644 --- a/conifer/plumbing/hooksystem.py +++ b/conifer/plumbing/hooksystem.py @@ -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: diff --git a/conifer/syrup/integration.py b/conifer/syrup/integration.py index b55f512..db75ea0 100644 --- a/conifer/syrup/integration.py +++ b/conifer/syrup/integration.py @@ -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. + """ diff --git a/conifer/syrup/views/items.py b/conifer/syrup/views/items.py index 1e7fb5c..f7a7e3f 100644 --- a/conifer/syrup/views/items.py +++ b/conifer/syrup/views/items.py @@ -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 diff --git a/conifer/templates/item/item_metadata.xhtml b/conifer/templates/item/item_metadata.xhtml index 666ce5b..16cdd62 100644 --- a/conifer/templates/item/item_metadata.xhtml +++ b/conifer/templates/item/item_metadata.xhtml @@ -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 ?>

Download the document

-

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.

+

+

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.

-- 2.11.0