equal
deleted
inserted
replaced
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, implements(IDownloadable), match_context_prop) |
38 __select__ = (one_line_rset() & implements(IDownloadable) & match_context_prop()) |
39 order = 10 |
39 order = 10 |
40 def cell_call(self, row, col, title=None, label=None, **kwargs): |
40 def cell_call(self, row, col, title=None, label=None, **kwargs): |
41 entity = self.entity(row, col) |
41 entity = self.entity(row, col) |
42 download_box(self.w, entity, title, label) |
42 download_box(self.w, entity, title, label) |
43 |
43 |
45 class DownloadView(baseviews.EntityView): |
45 class DownloadView(baseviews.EntityView): |
46 """this view is replacing the deprecated 'download' controller and allow |
46 """this view is replacing the deprecated 'download' controller and allow |
47 downloading of entities providing the necessary interface |
47 downloading of entities providing the necessary interface |
48 """ |
48 """ |
49 id = 'download' |
49 id = 'download' |
50 __selectors__ = (one_line_rset, implements(IDownloadable)) |
50 __select__ = one_line_rset() & implements(IDownloadable) |
51 |
51 |
52 templatable = False |
52 templatable = False |
53 content_type = 'application/octet-stream' |
53 content_type = 'application/octet-stream' |
54 binary = True |
54 binary = True |
55 add_to_breadcrumbs = False |
55 add_to_breadcrumbs = False |
72 |
72 |
73 |
73 |
74 class DownloadLinkView(baseviews.EntityView): |
74 class DownloadLinkView(baseviews.EntityView): |
75 """view displaying a link to download the file""" |
75 """view displaying a link to download the file""" |
76 id = 'downloadlink' |
76 id = 'downloadlink' |
77 __selectors__ = (implements(IDownloadable),) |
77 __select__ = implements(IDownloadable) |
78 title = None # should not be listed in possible views |
78 title = None # should not be listed in possible views |
79 |
79 |
80 |
80 |
81 def cell_call(self, row, col, title=None, **kwargs): |
81 def cell_call(self, row, col, title=None, **kwargs): |
82 entity = self.entity(row, col) |
82 entity = self.entity(row, col) |
84 self.w(u'<a href="%s">%s</a>' % (url, html_escape(title or entity.dc_title()))) |
84 self.w(u'<a href="%s">%s</a>' % (url, html_escape(title or entity.dc_title()))) |
85 |
85 |
86 |
86 |
87 |
87 |
88 class IDownloadablePrimaryView(baseviews.PrimaryView): |
88 class IDownloadablePrimaryView(baseviews.PrimaryView): |
89 __selectors__ = (implements(IDownloadable),) |
89 __select__ = implements(IDownloadable) |
90 #skip_attrs = ('eid', 'data',) # XXX |
90 #skip_attrs = ('eid', 'data',) # XXX |
91 |
91 |
92 def render_entity_title(self, entity): |
92 def render_entity_title(self, entity): |
93 self.w(u'<h1>%s %s</h1>' |
93 self.w(u'<h1>%s %s</h1>' |
94 % (entity.dc_type().capitalize(), |
94 % (entity.dc_type().capitalize(), |
116 """display all relations as side related""" |
116 """display all relations as side related""" |
117 return True |
117 return True |
118 |
118 |
119 |
119 |
120 class IDownloadableLineView(baseviews.OneLineView): |
120 class IDownloadableLineView(baseviews.OneLineView): |
121 __selectors__ = (implements(IDownloadable),) |
121 __select__ = implements(IDownloadable) |
122 |
122 |
123 def cell_call(self, row, col, title=None, **kwargs): |
123 def cell_call(self, row, col, title=None, **kwargs): |
124 """the secondary view is a link to download the file""" |
124 """the secondary view is a link to download the file""" |
125 entity = self.entity(row, col) |
125 entity = self.entity(row, col) |
126 url = html_escape(entity.absolute_url()) |
126 url = html_escape(entity.absolute_url()) |
136 return 0 |
136 return 0 |
137 return 1 |
137 return 1 |
138 |
138 |
139 class ImageView(baseviews.EntityView): |
139 class ImageView(baseviews.EntityView): |
140 id = 'image' |
140 id = 'image' |
141 __selectors__ = (implements(IDownloadable), |
141 __select__ = implements(IDownloadable) & score_entity(is_image) |
142 score_entity(is_image)) |
|
143 |
142 |
144 title = _('image') |
143 title = _('image') |
145 |
144 |
146 def call(self): |
145 def call(self): |
147 rset = self.rset |
146 rset = self.rset |