26 * startup views box |
26 * startup views box |
27 """ |
27 """ |
28 |
28 |
29 from cubicweb import _ |
29 from cubicweb import _ |
30 |
30 |
31 from warnings import warn |
|
32 |
|
33 from six import text_type, add_metaclass |
31 from six import text_type, add_metaclass |
34 |
32 |
35 from logilab.mtconverter import xml_escape |
33 from logilab.mtconverter import xml_escape |
36 from logilab.common.deprecation import class_deprecated |
|
37 |
34 |
38 from cubicweb import Unauthorized |
35 from cubicweb import Unauthorized |
39 from cubicweb.predicates import (match_user_groups, match_kwargs, |
36 from cubicweb.predicates import (match_user_groups, match_kwargs, |
40 non_final_entity, nonempty_rset, |
37 non_final_entity, nonempty_rset, |
41 match_context, contextual) |
38 match_context, contextual) |
228 self._cw.view(self.cw_extra_kwargs['vid'], self.cw_rset, w=w, |
225 self._cw.view(self.cw_extra_kwargs['vid'], self.cw_rset, w=w, |
229 initargs=self.cw_extra_kwargs) |
226 initargs=self.cw_extra_kwargs) |
230 |
227 |
231 # helper classes ############################################################## |
228 # helper classes ############################################################## |
232 |
229 |
233 @add_metaclass(class_deprecated) |
|
234 class SideBoxView(EntityView): |
|
235 """helper view class to display some entities in a sidebox""" |
|
236 __deprecation_warning__ = '[3.10] SideBoxView is deprecated, use RsetBox instead (%(cls)s)' |
|
237 |
|
238 __regid__ = 'sidebox' |
|
239 |
|
240 def call(self, title=u'', **kwargs): |
|
241 """display a list of entities by calling their <item_vid> view""" |
|
242 if 'dispctrl' in self.cw_extra_kwargs: |
|
243 # XXX do not modify dispctrl! |
|
244 self.cw_extra_kwargs['dispctrl'].setdefault('subvid', 'outofcontext') |
|
245 self.cw_extra_kwargs['dispctrl'].setdefault('use_list_limit', 1) |
|
246 if title: |
|
247 self.cw_extra_kwargs['title'] = title |
|
248 self.cw_extra_kwargs.setdefault('context', 'incontext') |
|
249 box = self._cw.vreg['ctxcomponents'].select( |
|
250 'rsetbox', self._cw, rset=self.cw_rset, vid='autolimited', |
|
251 **self.cw_extra_kwargs) |
|
252 box.render(self.w) |
|
253 |
|
254 |
|
255 class ContextualBoxLayout(component.Layout): |
230 class ContextualBoxLayout(component.Layout): |
256 __select__ = match_context('incontext', 'left', 'right') & contextual() |
231 __select__ = match_context('incontext', 'left', 'right') & contextual() |
257 # predefined class in cubicweb.css: contextualBox | contextFreeBox |
232 # predefined class in cubicweb.css: contextualBox | contextFreeBox |
258 cssclass = 'contextualBox' |
233 cssclass = 'contextualBox' |
259 |
234 |