equal
deleted
inserted
replaced
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.selectors import any_rset, appobject_selectable, match_user_groups |
20 from cubicweb.selectors import (any_rset, appobject_selectable, match_user_groups, non_final_entity) |
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 |
22 from cubicweb.web.box import BoxTemplate |
23 |
23 |
24 _ = unicode |
24 _ = unicode |
25 |
25 |
27 class EditBox(BoxTemplate): |
27 class EditBox(BoxTemplate): |
28 """ |
28 """ |
29 box with all actions impacting the entity displayed: edit, copy, delete |
29 box with all actions impacting the entity displayed: edit, copy, delete |
30 change state, add related entities |
30 change state, add related entities |
31 """ |
31 """ |
32 __select__ = any_rset() & BoxTemplate.__select__ |
32 __select__ = BoxTemplate.__select__ & non_final_entity() |
33 id = 'edit_box' |
33 id = 'edit_box' |
34 title = _('actions') |
34 title = _('actions') |
35 order = 2 |
35 order = 2 |
36 |
36 |
37 def call(self, **kwargs): |
37 def call(self, **kwargs): |
131 |
131 |
132 |
132 |
133 class SearchBox(BoxTemplate): |
133 class SearchBox(BoxTemplate): |
134 """display a box with a simple search form""" |
134 """display a box with a simple search form""" |
135 id = 'search_box' |
135 id = 'search_box' |
|
136 |
136 visible = True # enabled by default |
137 visible = True # enabled by default |
137 title = _('search') |
138 title = _('search') |
138 order = 0 |
139 order = 0 |
139 formdef = u"""<form action="%s"> |
140 formdef = u"""<form action="%s"> |
140 <table id="tsearch"><tr><td> |
141 <table id="tsearch"><tr><td> |
144 </td><td> |
145 </td><td> |
145 <input tabindex="%s" type="submit" id="rqlboxsubmit" value="" /> |
146 <input tabindex="%s" type="submit" id="rqlboxsubmit" value="" /> |
146 </td></tr></table> |
147 </td></tr></table> |
147 </form>""" |
148 </form>""" |
148 |
149 |
149 |
|
150 def call(self, view=None, **kwargs): |
150 def call(self, view=None, **kwargs): |
151 req = self.req |
151 req = self.req |
152 if req.form.pop('__fromsearchbox', None): |
152 if req.form.pop('__fromsearchbox', None): |
153 rql = req.form.get('rql', '') |
153 rql = req.form.get('rql', '') |
154 else: |
154 else: |
164 # boxes disabled by default ################################################### |
164 # boxes disabled by default ################################################### |
165 |
165 |
166 class PossibleViewsBox(BoxTemplate): |
166 class PossibleViewsBox(BoxTemplate): |
167 """display a box containing links to all possible views""" |
167 """display a box containing links to all possible views""" |
168 id = 'possible_views_box' |
168 id = 'possible_views_box' |
169 __select__ = match_user_groups('users', 'managers') |
169 __select__ = BoxTemplate.__select__ & match_user_groups('users', 'managers') |
170 |
170 |
|
171 visible = False |
171 title = _('possible views') |
172 title = _('possible views') |
172 order = 10 |
173 order = 10 |
173 visible = False |
|
174 |
174 |
175 def call(self, **kwargs): |
175 def call(self, **kwargs): |
176 box = BoxWidget(self.req._(self.title), self.id) |
176 box = BoxWidget(self.req._(self.title), self.id) |
177 views = [v for v in self.vreg.possible_views(self.req, self.rset) |
177 views = [v for v in self.vreg.possible_views(self.req, self.rset) |
178 if v.category != 'startupview'] |
178 if v.category != 'startupview'] |
189 """just display the RSS icon on uniform result set""" |
189 """just display the RSS icon on uniform result set""" |
190 id = 'rss' |
190 id = 'rss' |
191 __select__ = (BoxTemplate.__select__ |
191 __select__ = (BoxTemplate.__select__ |
192 & appobject_selectable('components', 'rss_feed_url')) |
192 & appobject_selectable('components', 'rss_feed_url')) |
193 |
193 |
|
194 visible = False |
194 order = 999 |
195 order = 999 |
195 visible = False |
|
196 |
196 |
197 def call(self, **kwargs): |
197 def call(self, **kwargs): |
198 try: |
198 try: |
199 rss = self.req.external_resource('RSS_LOGO') |
199 rss = self.req.external_resource('RSS_LOGO') |
200 except KeyError: |
200 except KeyError: |
206 |
206 |
207 |
207 |
208 class StartupViewsBox(BoxTemplate): |
208 class StartupViewsBox(BoxTemplate): |
209 """display a box containing links to all startup views""" |
209 """display a box containing links to all startup views""" |
210 id = 'startup_views_box' |
210 id = 'startup_views_box' |
|
211 |
211 visible = False # disabled by default |
212 visible = False # disabled by default |
212 title = _('startup views') |
213 title = _('startup views') |
213 order = 70 |
214 order = 70 |
214 |
215 |
215 def call(self, **kwargs): |
216 def call(self, **kwargs): |