web/views/baseviews.py
changeset 2472 a459a6ab78d0
parent 2471 3e2b50ece726
child 2645 91c71276f999
equal deleted inserted replaced
2471:3e2b50ece726 2472:a459a6ab78d0
    18 from rql import nodes
    18 from rql import nodes
    19 
    19 
    20 from logilab.mtconverter import TransformError, xml_escape, xml_escape
    20 from logilab.mtconverter import TransformError, xml_escape, xml_escape
    21 
    21 
    22 from cubicweb import NoSelectableObject
    22 from cubicweb import NoSelectableObject
    23 from cubicweb.selectors import yes, empty_rset
    23 from cubicweb.selectors import yes, empty_rset, one_etype_rset
    24 from cubicweb.schema import display_name
    24 from cubicweb.schema import display_name
    25 from cubicweb.view import EntityView, AnyRsetView, View
    25 from cubicweb.view import EntityView, AnyRsetView, View
    26 from cubicweb.common.uilib import cut, printable_value
    26 from cubicweb.common.uilib import cut, printable_value
    27 
    27 
    28 
    28 
   283     """list without bullets"""
   283     """list without bullets"""
   284     id = 'simplelist'
   284     id = 'simplelist'
   285     redirect_vid = 'incontext'
   285     redirect_vid = 'incontext'
   286 
   286 
   287 
   287 
   288 class AdaptedListView(ListItemView):
   288 class AdaptedListView(EntityView):
   289     """list of entities of the same type"""
   289     """list of entities of the same type"""
   290     id = 'adaptedlist'
   290     id = 'adaptedlist'
   291     __select__ = non_final_entity() & one_etype_rset()
   291     __select__ = one_etype_rset()
   292     item_vid = 'adaptedlistitem'
   292     item_vid = 'adaptedlistitem'
   293 
   293 
   294     @property
   294     @property
   295     def title(self):
   295     def title(self):
   296         etype = iter(self.rset.column_types(0)).next()
   296         etype = iter(self.rset.column_types(0)).next()
   297         return display_name(self.req, etype, form='plural'))
   297         return display_name(self.req, etype, form='plural')
   298 
   298 
   299     def call(self, **kwargs):
   299     def call(self, **kwargs):
   300         """display a list of entities by calling their <item_vid> view"""
   300         """display a list of entities by calling their <item_vid> view"""
   301         if not 'vtitle' in self.req.form:
   301         if not 'vtitle' in self.req.form:
   302             self.w(u'<h1>%s</h1>' % self.title)
   302             self.w(u'<h1>%s</h1>' % self.title)