# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1251278482 -7200
#      Wed Aug 26 11:21:22 2009 +0200
# Node ID 8d4e0178fbe85ffeb0d6c25d120b9797daa661b3
# Parent  49871aef886ba32b65d7caa0b7f70effd96ec14f
#345371: replace full_list by using adaptedlist view from cw

diff --git a/views.py b/views.py
--- a/views.py
+++ b/views.py
@@ -42,7 +42,7 @@
         rset = entity.related('entry_of', 'object')
         strio = UStringIO()
         self.pagination(self.req, rset, strio.write, page_size=10)
-        self.wview('full_list', rset, 'null')
+        self.wview('adaptedlist', rset, 'null')
         self.w(strio.getvalue())
 
 
@@ -75,9 +75,7 @@
         nmb_entries = self.req.execute(self.countrql, args)[0][0]
         label = u'%s %s [%s]' % (self.req._(calendar.MONTHNAMES[month-1]), year,
                                  nmb_entries)
-        vtitle = '%s %s' % (self.req._('BlogEntry_plural'), label)
-        url = html_escape(self.build_url('view', rql=rql, vtitle=vtitle,
-                                         vid='full_list'))
+        url = html_escape(self.build_url('view', rql=rql))
         link = u'<a href="%s" title="">%s</a>' % (url, label)
         items.append( u'<li class="">%s</li>\n' % link )
 
@@ -152,7 +150,7 @@
         rqlst = rset.syntax_tree()
         rqlst.set_limit(None)
         rql = rqlst.as_string(kwargs=rset.args)
-        url = self.build_url('view', vid='full_list', rql=rql, page_size=10)
+        url = self.build_url('view', rql=rql, page_size=10)
         box.append(BoxLink(url,  u'[%s]' % self.req._(u'see more')))
         rss_icon = self.req.external_resource('RSS_LOGO_16')
         # FIXME - could use rss_url defined as a property if available
@@ -163,24 +161,21 @@
         box.render(self.w)
 
 
-## list views #################################################################
+## list views ##################################################################
 
-class BlogEntryListItemView(baseviews.ListItemView):
-    id = 'full_list'
-    __select__ = implements('BlogEntry')
-    redirect_vid = 'blog'
+class BlogEntryAdaptedListView(baseviews.AdaptedListView):
+    __select__ = baseviews.AdaptedListView.__select__ & implements('BlogEntry')
 
     def call(self, **kwargs):
-        """display a list of entities by calling their <item_vid> view
-        """
-        entity = self.entity(0,0)
         self.req.add_css('cubes.blog.css')
-        if not 'vtitle' in self.req.form:
-            self.w(u'<h1>%s</h1>' % display_name(self.req, 'BlogEntry', form='plural'))
-        super(BlogEntryListItemView, self).call(**kwargs)
+        super(BlogEntryAdaptedListView, self).call(**kwargs)
+
+class BlogEntryAdaptedListItemView(baseviews.AdaptedListItemView):
+    __select__ = baseviews.AdaptedListView.__select__ & implements('BlogEntry')
+    redirect_vid = 'blog'
 
 
-class BlogEntryBlogView(baseviews.ListItemView):
+class BlogEntryBlogView(EntityView):
     id = 'blog'
     __select__ = implements('BlogEntry')
 
@@ -197,8 +192,7 @@
                                                            creator.surname)
             rql = 'Any X ORDERBY D DESC WHERE X is BlogEntry, X created_by Y, '\
                   'Y eid %s, X creation_date D' % creator.eid
-            url = self.build_url('view', vid="full_list", rql=rql, vtitle=vtitle,
-                                 page_size = 10)
+            url = self.build_url('view', rql=rql, vtitle=vtitle, page_size=10)
             w(u'%s <a href="%s">%s %s</a>' % (_('by'), html_escape(url),
                                               creator.firstname,
                                               creator.surname))