48 __select__ = (one_line_rset() & implements(IDownloadable) & |
48 __select__ = (one_line_rset() & implements(IDownloadable) & |
49 match_context_prop() & ~score_entity(is_image)) |
49 match_context_prop() & ~score_entity(is_image)) |
50 order = 10 |
50 order = 10 |
51 |
51 |
52 def cell_call(self, row, col, title=None, label=None, **kwargs): |
52 def cell_call(self, row, col, title=None, label=None, **kwargs): |
53 entity = self.entity(row, col) |
53 entity = self.rset.get_entity(row, col) |
54 download_box(self.w, entity, title, label) |
54 download_box(self.w, entity, title, label) |
55 |
55 |
56 |
56 |
57 class DownloadView(EntityView): |
57 class DownloadView(EntityView): |
58 """this view is replacing the deprecated 'download' controller and allow |
58 """this view is replacing the deprecated 'download' controller and allow |
89 __select__ = implements(IDownloadable) |
89 __select__ = implements(IDownloadable) |
90 title = None # should not be listed in possible views |
90 title = None # should not be listed in possible views |
91 |
91 |
92 |
92 |
93 def cell_call(self, row, col, title=None, **kwargs): |
93 def cell_call(self, row, col, title=None, **kwargs): |
94 entity = self.entity(row, col) |
94 entity = self.rset.get_entity(row, col) |
95 url = xml_escape(entity.download_url()) |
95 url = xml_escape(entity.download_url()) |
96 self.w(u'<a href="%s">%s</a>' % (url, xml_escape(title or entity.dc_title()))) |
96 self.w(u'<a href="%s">%s</a>' % (url, xml_escape(title or entity.dc_title()))) |
97 |
97 |
98 |
98 |
99 class IDownloadablePrimaryView(primary.PrimaryView): |
99 class IDownloadablePrimaryView(primary.PrimaryView): |
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 oneline view is a link to download the file""" |
126 entity = self.entity(row, col) |
126 entity = self.rset.get_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>]' % |
131 (url, name, durl, self.req._('download'))) |
131 (url, name, durl, self.req._('download'))) |
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, width=None, height=None, link=False): |
147 def cell_call(self, row, col, width=None, height=None, link=False): |
148 entity = self.entity(row, col) |
148 entity = self.rset.get_entity(row, col) |
149 #if entity.data_format.startswith('image/'): |
149 #if entity.data_format.startswith('image/'): |
150 imgtag = 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: |
152 if width: |
153 imgtag += u'width="%i" ' % width |
153 imgtag += u'width="%i" ' % width |