web/views/idownloadable.py
changeset 326 44b6345ccd3c
parent 249 5ab64969df20
child 431 18b4dd650ef8
equal deleted inserted replaced
325:93051a377541 326:44b6345ccd3c
     9 from logilab.mtconverter import BINARY_ENCODINGS, TransformError, html_escape
     9 from logilab.mtconverter import BINARY_ENCODINGS, TransformError, html_escape
    10 
    10 
    11 from cubicweb.interfaces import IDownloadable
    11 from cubicweb.interfaces import IDownloadable
    12 from cubicweb.common.mttransforms import ENGINE
    12 from cubicweb.common.mttransforms import ENGINE
    13 from cubicweb.common.selectors import (one_line_rset, score_entity_selector,
    13 from cubicweb.common.selectors import (one_line_rset, score_entity_selector,
    14                                        interface_selector)
    14                                        interface_selector, contextprop_selector)
    15 from cubicweb.web.box import EntityBoxTemplate
    15 from cubicweb.web.box import EntityBoxTemplate
    16 from cubicweb.web.views import baseviews
    16 from cubicweb.web.views import baseviews
    17 
    17 
    18 _ = unicode
    18 _ = unicode
    19 
    19 
    33     w(u'</div>\n</div>\n')
    33     w(u'</div>\n</div>\n')
    34 
    34 
    35     
    35     
    36 class DownloadBox(EntityBoxTemplate):
    36 class DownloadBox(EntityBoxTemplate):
    37     id = 'download_box'
    37     id = 'download_box'
    38     __selectors__ = (one_line_rset, interface_selector)
    38     __selectors__ = (one_line_rset, interface_selector, contextprop_selector)
    39     accepts_interfaces = (IDownloadable,)
    39     accepts_interfaces = (IDownloadable,)
    40     order = 10
    40     order = 10
    41     def cell_call(self, row, col, title=None, label=None, **kwargs):
    41     def cell_call(self, row, col, title=None, label=None, **kwargs):
    42         entity = self.entity(row, col)
    42         entity = self.entity(row, col)
    43         download_box(self.w, entity, title, label)
    43         download_box(self.w, entity, title, label)
   119     def is_side_related(self, rschema, eschema):
   119     def is_side_related(self, rschema, eschema):
   120         """display all relations as side related"""
   120         """display all relations as side related"""
   121         return True
   121         return True
   122 
   122 
   123 
   123 
   124     def render_side_related(self, entity, siderelations):
       
   125         download_box(self.w, entity)
       
   126         super(IDownloadablePrimaryView, self).render_side_related(entity, siderelations)
       
   127 
       
   128 class IDownloadableLineView(baseviews.OneLineView):
   124 class IDownloadableLineView(baseviews.OneLineView):
   129     __selectors__ = (interface_selector,)
   125     __selectors__ = (interface_selector,)
   130     # don't kick default oneline view
   126     # don't kick default oneline view
   131     accepts_interfaces = (IDownloadable,)
   127     accepts_interfaces = (IDownloadable,)
   132     
   128