[idownloadable] oneline view display entity's default title instead of file name, while download box display file name stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 07 Jan 2011 15:21:56 +0100
branchstable
changeset 6793 308cf1eaf576
parent 6792 8834d9d91b66
child 6794 140d42b41b31
[idownloadable] oneline view display entity's default title instead of file name, while download box display file name
web/views/idownloadable.py
--- a/web/views/idownloadable.py	Fri Jan 07 15:21:54 2011 +0100
+++ b/web/views/idownloadable.py	Fri Jan 07 15:21:56 2011 +0100
@@ -62,10 +62,12 @@
 
     def render_body(self, w):
         for item in self.items:
+            idownloadable = item.cw_adapt_to('IDownloadable')
             w(u'<a href="%s"><img src="%s" alt="%s"/> %s</a>'
-              % (xml_escape(item.cw_adapt_to('IDownloadable').download_url()),
+              % (xml_escape(idownloadable.download_url()),
                  self._cw.uiprops['DOWNLOAD_ICON'],
-                 self._cw._('download icon'), xml_escape(item.dc_title())))
+                 self._cw._('download icon'),
+                 xml_escape(idownloadable.download_file_name())))
 
 
 class DownloadView(EntityView):
@@ -154,7 +156,7 @@
         return False
 
 
-class IDownloadableLineView(baseviews.OneLineView):
+class IDownloadableOneLineView(baseviews.OneLineView):
     __select__ = adaptable('IDownloadable')
 
     def cell_call(self, row, col, title=None, **kwargs):
@@ -162,7 +164,7 @@
         entity = self.cw_rset.get_entity(row, col)
         url = xml_escape(entity.absolute_url())
         adapter = entity.cw_adapt_to('IDownloadable')
-        name = xml_escape(title or adapter.download_file_name())
+        name = xml_escape(title or entity.dc_title())
         durl = xml_escape(adapter.download_url())
         self.w(u'<a href="%s">%s</a> [<a href="%s">%s</a>]' %
                (url, name, durl, self._cw._('download')))