fix deprecation warning due to old table view usage. Closes #2148154

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changeset2b5693f63bdb
branchstable
phasepublic
hiddenno
parent revision#e338119b1f55 default is stable
child revision#6d84762b3632 fix two pre 3.14 warnings: field vocab should be unicode (pretty old), skip_copy_for renamed (3.14)
files modified by this revision
views/startup.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1326369764 -3600
# Thu Jan 12 13:02:44 2012 +0100
# Branch stable
# Node ID 2b5693f63bdb1092f3ef97d1c446222c136ac87a
# Parent e338119b1f55a21be09fc119bab2b19432487bfd
fix deprecation warning due to old table view usage. Closes #2148154

diff --git a/views/startup.py b/views/startup.py
@@ -7,11 +7,11 @@
1  __docformat__ = "restructuredtext en"
2  _ = unicode
3 
4  from logilab.mtconverter import xml_escape
5 
6 -from cubicweb.web.views import startup
7 +from cubicweb.web.views import startup, tableview
8 
9 
10  class IndexView(startup.IndexView):
11      title = _('Index')
12      add_etype_links = ('Project',)
@@ -88,63 +88,59 @@
13          if user.is_in_group('users'):
14              rql = ('Any X, NOW - CD, P ORDERBY CD DESC LIMIT 5 WHERE U interested_in P, '
15                     'U eid %(x)s, X concerns P, X creation_date CD')
16              rset = self._cw.execute(rql, {'x': user.eid})
17              self.wview('table', rset, 'null',
18 -                       headers=[_(u'Recent tickets in my projects'), _(u'Date'), _(u'Project')],
19 -                       subvid='incontext', displayactions=False)
20 +                       headers=[_(u'Recent tickets in my projects'), _(u'Date'),
21 +                                _(u'Project')])
22          # tickets
23          if user.is_in_group('guests'):
24              rql = 'Any X, NOW - CD, P ORDERBY CD DESC LIMIT 5 WHERE X concerns P, X creation_date CD'
25              rset = self._cw.execute(rql)
26          else:
27              rql = ('Any X, NOW - CD, P ORDERBY CD DESC LIMIT 5 WHERE X concerns P, '
28                     'X creation_date CD, NOT U interested_in P, U eid %(x)s')
29              rset = self._cw.execute(rql, {'x': user.eid})
30          self.wview('table', rset, 'null',
31 -                   headers=[_(u'Recent tickets'), _(u'Date'),_(u'Project')],
32 -                   subvid='incontext', displayactions=False)
33 +                   headers=[_(u'Recent tickets'), _(u'Date'),_(u'Project')])
34          # upcoming versions
35          rset = self._cw.execute(self.upcoming_versions)
36 -        self.wview('table', rset, 'null',
37 -                   headers=[_(u'Upcoming versions'), _(u'Planned on')],
38 -                   subvid='outofcontext', displayactions=False)
39 +        self.wview('ooctable', rset, 'null',
40 +                   headers=[_(u'Upcoming versions'), _(u'Planned on')])
41          # see all upcoming versions
42          if len(rset) == 5:
43              rql =  ('Any X,D ORDERBY D DESC WHERE X is Version, X prevision_date D, '
44                      'NOT X prevision_date NULL, X in_state S, S name "dev"')
45              self.w(u'<a onmouseover=\"$(this).addClass(\'highlighted\')\" ' \
46                      'onmouseout=\"$(this).removeClass(\'highlighted\')\" ' \
47                      'class="seemore" href="%s">%s</a>' %
48 -                   (xml_escape(self._cw.build_url('view', rql=rql, vid='table', subvid='outofcontext')),
49 +                   (xml_escape(self._cw.build_url('view', rql=rql, vid='ooctable')),
50                      self._cw._(u'All upcoming versions...')))
51          # latest releases
52          rset = self._cw.execute(self.latest_releases)
53 -        self.wview('table', rset, 'null',
54 -                   headers=[_(u'Latest releases'), _(u'Published on')],
55 -                   subvid='outofcontext', displayactions=False)
56 +        self.wview('ooctable', rset, 'null',
57 +                   headers=[_(u'Latest releases'), _(u'Published on')])
58          # see all latest releases
59          if len(rset) == 5:
60              rql = ('Any X,D ORDERBY D DESC WHERE X is Version, X publication_date D, '
61                     'NOT X publication_date NULL, X in_state S, S name "published"')
62              self.w(u'<a onmouseover=\"$(this).addClass(\'highlighted\')\" ' \
63                      'onmouseout=\"$(this).removeClass(\'highlighted\')\" ' \
64                      'class="seemore" href="%s">%s</a>' %
65 -                   (xml_escape(self._cw.build_url('view', rql=rql, vid='table', subvid='outofcontext')),
66 +                   (xml_escape(self._cw.build_url('view', rql=rql, vid='ooctable')),
67                      self._cw._(u'All latest releases...')))
68          # new projects
69          rset = self._cw.execute(self.new_projects)
70          self.wview('table', rset, 'null',
71 -                   headers=[_(u'New projects'), _(u'Description')],
72 -                   subvid='oneline', displayactions=False)
73 +                   headers=[_(u'New projects'), _(u'Description')])
74          # see all new projects
75          if len(rset) == 5:
76              rql = 'Any P,S ORDERBY CD DESC WHERE P is Project, P summary S, P creation_date CD'
77              self.w(u'<a onmouseover=\"$(this).addClass(\'highlighted\')\" ' \
78                      'onmouseout=\"$(this).removeClass(\'highlighted\')\" ' \
79                      'class="seemore" href="%s">%s</a>' %
80 -                   (xml_escape(self._cw.build_url('view', rql=rql, vid='table', subvid='outofcontext')),
81 +                   (xml_escape(self._cw.build_url('view', rql=rql, vid='table')),
82                      self._cw._(u'All new projects...')))
83          w(u'</td>')
84 
85      def call(self):
86          w = self.w
@@ -154,8 +150,12 @@
87          self._left_section()
88          self._right_section()
89          w(u'</tr></table>\n')
90 
91 
92 +class OOCRsetTableView(tableview.RsetTableView):
93 +    __regid__ = 'ooctable'
94 +    nonfinalvid = 'outofcontext'
95 +
96  def registration_callback(vreg):
97      vreg.register_all(globals().values(), __name__, (IndexView,))
98      vreg.register_and_replace(IndexView, startup.IndexView)