# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1235573739 -3600 # Node ID b1f68f725fe93c500a3156faafa9fea1c94599c3 # Parent ae7044a06efb7a02c6ea85524ac7a7bf5ad9cc93 don't show download box nor download link for images, by default hide name attribute even if not specified in the interface diff -r ae7044a06efb -r b1f68f725fe9 web/views/idownloadable.py --- a/web/views/idownloadable.py Wed Feb 25 15:54:55 2009 +0100 +++ b/web/views/idownloadable.py Wed Feb 25 15:55:39 2009 +0100 @@ -35,9 +35,19 @@ class DownloadBox(EntityBoxTemplate): id = 'download_box' - __selectors__ = (one_line_rset, implement_interface, match_context_prop) + # XXX primary_view selector ? + __selectors__ = (one_line_rset, implement_interface, match_context_prop, score_entity_selector) accepts_interfaces = (IDownloadable,) order = 10 + + @classmethod + def score_entity(cls, entity): + mt = entity.download_content_type() + # no download box for images + if mt and mt.startswith('image/'): + return 0 + return 1 + def cell_call(self, row, col, title=None, label=None, **kwargs): entity = self.entity(row, col) download_box(self.w, entity, title, label) @@ -90,8 +100,9 @@ class IDownloadablePrimaryView(baseviews.PrimaryView): __selectors__ = (implement_interface,) - #skip_attrs = ('eid', 'data',) # XXX accepts_interfaces = (IDownloadable,) + # XXX File/Image attributes but this is not specified in the IDownloadable interface + skip_attrs = baseviews.PrimaryView.skip_attrs + ('data', 'name') def render_entity_title(self, entity): self.w(u'