From 264ee455816f651438cc3b096ab21e538c4bcac6 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Sat, 13 Nov 2010 01:35:41 +0000 Subject: [PATCH] force ELEC document links to go to Meta page, not directly to download. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1064 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/models.py | 20 ++++++++++++-------- conifer/templates/item/item_metadata.xhtml | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index 040dadc..0ef3dc3 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -598,18 +598,22 @@ class Item(BaseModel): def needs_meta_link(self): """Should an 'About' link be displayed for this item?""" - return self.item_type in ('ELEC', 'URL') + return self.item_type in ('URL',) - def item_url(self, suffix='', force_local_url=False): - # I'm not fond of this being here. I think I'll leave this and - # site_url non-implemented, and monkey-patch them in views.py. - req = get_request() - prefix = req.META['SCRIPT_NAME'] - if self.item_type == 'ELEC' and suffix == '': + def item_download_url(self): + if self.item_type != 'ELEC': + return None + else: + req = get_request() + prefix = req.META['SCRIPT_NAME'] return '%s/site/%d/item/%d/dl/%s' % ( prefix, self.site_id, self.id, self.fileobj.name.split('/')[-1]) - if self.item_type == 'URL' and suffix == '' and not force_local_url: + + def item_url(self, suffix=''): + req = get_request() + prefix = req.META['SCRIPT_NAME'] + if self.item_type == 'URL' and suffix == '': return self.url else: return '%s/site/%d/item/%d/%s' % ( diff --git a/conifer/templates/item/item_metadata.xhtml b/conifer/templates/item/item_metadata.xhtml index a45b591..c381b08 100644 --- a/conifer/templates/item/item_metadata.xhtml +++ b/conifer/templates/item/item_metadata.xhtml @@ -48,7 +48,7 @@ is_editor = site.can_edit(request.user) - +
Content type${item.fileobj_mimetype}
Size${item.fileobj.size} bytes
Download
Download
-- 2.11.0