8 additional (disabled by default) boxes |
8 additional (disabled by default) boxes |
9 * schema box |
9 * schema box |
10 * startup views box |
10 * startup views box |
11 |
11 |
12 :organization: Logilab |
12 :organization: Logilab |
13 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
13 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
14 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
14 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
15 """ |
15 """ |
16 __docformat__ = "restructuredtext en" |
16 __docformat__ = "restructuredtext en" |
17 |
17 |
18 from logilab.mtconverter import html_escape |
18 from logilab.mtconverter import html_escape |
19 |
19 |
20 from cubicweb.common.selectors import (any_rset, appobject_selectable) |
20 from cubicweb.common.selectors import any_rset, appobject_selectable |
21 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem |
21 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem |
22 from cubicweb.web.box import BoxTemplate, ExtResourcesBoxTemplate |
22 from cubicweb.web.box import BoxTemplate, ExtResourcesBoxTemplate |
23 |
23 |
24 _ = unicode |
24 _ = unicode |
25 |
25 |
173 require_groups = ('users', 'managers') |
173 require_groups = ('users', 'managers') |
174 visible = False |
174 visible = False |
175 |
175 |
176 def call(self, **kwargs): |
176 def call(self, **kwargs): |
177 box = BoxWidget(self.req._(self.title), self.id) |
177 box = BoxWidget(self.req._(self.title), self.id) |
178 actions = [v for v in self.vreg.possible_views(self.req, self.rset) |
178 views = [v for v in self.vreg.possible_views(self.req, self.rset) |
179 if v.category != 'startupview'] |
179 if v.category != 'startupview'] |
180 for category, actions in self.sort_actions(actions): |
180 for category, views in self.sort_actions(views): |
181 menu = BoxMenu(category) |
181 menu = BoxMenu(category) |
182 for action in actions: |
182 for view in views: |
183 menu.append(self.box_action(action)) |
183 menu.append(self.box_action(view)) |
184 box.append(menu) |
184 box.append(menu) |
185 if not box.is_empty(): |
185 if not box.is_empty(): |
186 box.render(self.w) |
186 box.render(self.w) |
187 |
|
188 |
187 |
189 |
188 |
190 class RSSIconBox(ExtResourcesBoxTemplate): |
189 class RSSIconBox(ExtResourcesBoxTemplate): |
191 """just display the RSS icon on uniform result set""" |
190 """just display the RSS icon on uniform result set""" |
192 __selectors__ = ExtResourcesBoxTemplate.__selectors__ + (appobject_selectable('components', 'rss_feed_url'),) |
191 __selectors__ = ExtResourcesBoxTemplate.__selectors__ + (appobject_selectable('components', 'rss_feed_url'),) |
201 url = urlgetter.feed_url() |
200 url = urlgetter.feed_url() |
202 rss = self.req.external_resource('RSS_LOGO') |
201 rss = self.req.external_resource('RSS_LOGO') |
203 self.w(u'<a href="%s"><img src="%s" alt="rss"/></a>\n' % (html_escape(url), rss)) |
202 self.w(u'<a href="%s"><img src="%s" alt="rss"/></a>\n' % (html_escape(url), rss)) |
204 |
203 |
205 |
204 |
206 ## warning("schemabox ne marche plus pour le moment") |
|
207 ## class SchemaBox(BoxTemplate): |
|
208 ## """display a box containing link to list of entities by type""" |
|
209 ## id = 'schema_box' |
|
210 ## visible = False # disabled by default |
|
211 ## title = _('entity list') |
|
212 ## order = 60 |
|
213 |
|
214 ## def call(self, **kwargs): |
|
215 ## box = BoxWidget(self.req._(title), self.id) |
|
216 ## for etype in self.config.etypes(self.req.user, 'read'): |
|
217 ## view = self.vreg.select_view('list', self.req, self.etype_rset(etype)) |
|
218 ## box.append(self.mk_action(display_name(self.req, etype, 'plural'), |
|
219 ## view.url(), etype=etype)) |
|
220 ## if not box.is_empty(): |
|
221 ## box.render(self.w) |
|
222 |
|
223 class StartupViewsBox(BoxTemplate): |
205 class StartupViewsBox(BoxTemplate): |
224 """display a box containing links to all startup views""" |
206 """display a box containing links to all startup views""" |
225 id = 'startup_views_box' |
207 id = 'startup_views_box' |
226 visible = False # disabled by default |
208 visible = False # disabled by default |
227 title = _('startup views') |
209 title = _('startup views') |