web/views/idownloadable.py
changeset 2524 2d0c04c8cbe4
parent 2470 569d6641f08c
child 2530 3cd117ecc3a8
equal deleted inserted replaced
2514:c745dfb2734e 2524:2d0c04c8cbe4
   120 
   120 
   121 class IDownloadableLineView(baseviews.OneLineView):
   121 class IDownloadableLineView(baseviews.OneLineView):
   122     __select__ = implements(IDownloadable)
   122     __select__ = implements(IDownloadable)
   123 
   123 
   124     def cell_call(self, row, col, title=None, **kwargs):
   124     def cell_call(self, row, col, title=None, **kwargs):
   125         """the oneline view is a link to download the file"""
   125         """the secondary view is a link to download the file"""
   126         entity = self.entity(row, col)
   126         entity = self.entity(row, col)
   127         url = xml_escape(entity.absolute_url())
   127         url = xml_escape(entity.absolute_url())
   128         name = xml_escape(title or entity.download_file_name())
   128         name = xml_escape(title or entity.download_file_name())
   129         durl = xml_escape(entity.download_url())
   129         durl = xml_escape(entity.download_url())
   130         self.w(u'<a href="%s">%s</a> [<a href="%s">%s</a>]' %
   130         self.w(u'<a href="%s">%s</a> [<a href="%s">%s</a>]' %
   142         for i in xrange(len(rset)):
   142         for i in xrange(len(rset)):
   143             self.w(u'<div class="efile">')
   143             self.w(u'<div class="efile">')
   144             self.wview(self.id, rset, row=i, col=0)
   144             self.wview(self.id, rset, row=i, col=0)
   145             self.w(u'</div>')
   145             self.w(u'</div>')
   146 
   146 
   147     def cell_call(self, row, col):
   147     def cell_call(self, row, col, width=None, height=None, link=False):
   148         entity = self.entity(row, col)
   148         entity = self.entity(row, col)
   149         #if entity.data_format.startswith('image/'):
   149         #if entity.data_format.startswith('image/'):
   150         self.w(u'<img src="%s" alt="%s"/>' % (xml_escape(entity.download_url()),
   150         imgtag = u'<img src="%s" alt="%s" ' % (xml_escape(entity.download_url()),
   151                                               xml_escape(entity.download_file_name())))
   151                                                xml_escape(entity.download_file_name()))
       
   152         if width:
       
   153             imgtag += u'width="%i" ' % width
       
   154         if height:
       
   155             imgtag += u'height="%i" ' % height
       
   156         imgtag += u'/>'
       
   157         if link:
       
   158             self.w(u'<a href="%s" alt="%s">%s</a>' % (entity.absolute_url(vid='download'),
       
   159                                                       self.req._('download image'),
       
   160                                                       imgtag))
       
   161         else:
       
   162             self.w(imgtag)
   152 
   163 
       
   164