web/views/idownloadable.py
branchstable
changeset 6009 9633d2376687
parent 6004 d17d3b34bc12
child 6048 4695b1ee58a0
equal deleted inserted replaced
6008:e1c43115af3b 6009:9633d2376687
   111 
   111 
   112 class IDownloadablePrimaryView(primary.PrimaryView):
   112 class IDownloadablePrimaryView(primary.PrimaryView):
   113     __select__ = adaptable('IDownloadable')
   113     __select__ = adaptable('IDownloadable')
   114 
   114 
   115     def render_entity_attributes(self, entity):
   115     def render_entity_attributes(self, entity):
   116         super(IDownloadablePrimaryView, self).render_entity_attributes(entity)
       
   117         self.w(u'<div class="content">')
   116         self.w(u'<div class="content">')
   118         adapter = entity.cw_adapt_to('IDownloadable')
   117         adapter = entity.cw_adapt_to('IDownloadable')
   119         contenttype = adapter.download_content_type()
   118         contenttype = adapter.download_content_type()
   120         if contenttype.startswith('image/'):
   119         if contenttype.startswith('image/'):
   121             self._cw.add_js('cubicweb.image.js')
   120             self._cw.add_js('cubicweb.image.js')
   122             self.wview('image', entity.cw_rset, row=entity.cw_row, col=entity.cw_col,
   121             self.wview('image', entity.cw_rset, row=entity.cw_row, col=entity.cw_col,
   123                        link=True, klass='contentimage')
   122                        link=True, klass='contentimage')
       
   123             super(IDownloadablePrimaryView, self).render_entity_attributes(entity)
   124         else:
   124         else:
       
   125             super(IDownloadablePrimaryView, self).render_entity_attributes(entity)
   125             self.wview('downloadlink', entity.cw_rset, title=self._cw._('download'), row=entity.cw_row)
   126             self.wview('downloadlink', entity.cw_rset, title=self._cw._('download'), row=entity.cw_row)
   126             self.render_data(entity, contenttype, 'text/html')
   127             self.render_data(entity, contenttype, 'text/html')
   127         self.w(u'</div>')
   128         self.w(u'</div>')
   128 
   129 
   129     def render_data(self, entity, sourcemt, targetmt):
   130     def render_data(self, entity, sourcemt, targetmt):