force ELEC document links to go to Meta page, not directly to download.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sat, 13 Nov 2010 01:35:41 +0000 (01:35 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sat, 13 Nov 2010 01:35:41 +0000 (01:35 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1064 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/syrup/models.py
conifer/templates/item/item_metadata.xhtml

index 040dadc..0ef3dc3 100644 (file)
@@ -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' % (
index a45b591..c381b08 100644 (file)
@@ -48,7 +48,7 @@ is_editor = site.can_edit(request.user)
       <table class="metadata_table">
        <tr><th>Content type</th><td>${item.fileobj_mimetype}</td></tr>
        <tr><th>Size</th><td>${item.fileobj.size} bytes</td></tr>
-       <tr><th/><td><a class="bigdownload" href="${item.item_url()}">Download</a></td></tr>
+       <tr><th/><td><a class="bigdownload" href="${item.item_download_url()}">Download</a></td></tr>
       </table>
     </div>
     <div py:if="item.marcxml">