Switch TestExecution tables to new table views (closes #1965435) stable
authorJulien Cristau <julien.cristau@logilab.fr>
Thu, 22 Dec 2011 12:06:23 +0100
branchstable
changeset 804 83292caad00c
parent 803 8c0027f1a811
child 805 35bdc8c657d6
Switch TestExecution tables to new table views (closes #1965435) Use three variants: - with all columns - with everything but the PE, for use in PE executions tab and project test reports tab - with everything but the TC, for use in TC executions tab
views/primary.py
views/testexecution.py
views/tracker.py
--- a/views/primary.py	Wed Dec 21 17:52:02 2011 +0100
+++ b/views/primary.py	Thu Dec 22 12:06:23 2011 +0100
@@ -135,14 +135,14 @@
 
     html_headers = no_robot_index
 
-    def cell_call(self, row, col):
+    def entity_call(self, entity):
         rset = self._cw.execute(
             'Any T,TC,T,TB,TST,TET,TF, TS ORDERBY TST DESC WHERE '
             'T status TS, T using_config TC, T branch TB, '
             'T starttime TST, T endtime TET, T log_file TF?, '
             'T using_environment PE, PE eid %(pe)s',
-            {'pe': self.cw_rset[row][col]})
-        self.wview('apycot.te.summarytable', rset, 'noresult', showpe=False)
+            {'pe': entity.eid})
+        self.wview('apycot.te.nopetable', rset, 'noresult')
 
 
 class PETestConfigView(EntityView):
@@ -246,14 +246,14 @@
 
     html_headers = no_robot_index
 
-    def cell_call(self, row, col):
+    def entity_call(self, entity):
         rset = self._cw.execute(
             'Any T,PE,T,TB,TST,TET,TF, TS,PEN ORDERBY TST DESC WHERE '
             'T status TS, T using_config TC, T using_environment PE, '
             'T branch TB, T starttime TST, T endtime TET, T log_file TF?, '
             'PE name PEN, TC eid %(tc)s',
-            {'tc': self.cw_rset[row][col]})
-        self.wview('apycot.tc.te.summarytable', rset, 'noresult')
+            {'tc': entity.eid})
+        self.wview('apycot.te.notctable', rset, 'noresult')
 
 
 class TCStartModeView(EntityView):
@@ -268,25 +268,6 @@
             self.w(self._cw._(' (inherited)'))
 
 
-class TCTESummaryTable(tableview.TableView):
-    __select__ = is_instance('TestExecution')
-    __regid__ = 'apycot.tc.te.summarytable'
-
-    html_headers = no_robot_index
-
-    def call(self):
-        self._cw.add_css('cubes.apycot.css')
-        _ = self._cw._
-        super(TCTESummaryTable, self).call(
-            displayfilter=True, paginate=True,
-            headers=[_('TestExecution'), _('ProjectEnvironment'),
-                     _('checks'), _('branch'),
-                     _('starttime'), _('endtime'), _('archive')],
-            cellvids={0: 'apycot.te.statuscell',
-                      2: 'apycot.te.summarycell',
-                      6: 'icon'})
-
-
 def _available_branches(form, field):
     tc = form.edited_entity
     environment = form.cw_extra_kwargs['environment']
--- a/views/testexecution.py	Wed Dec 21 17:52:02 2011 +0100
+++ b/views/testexecution.py	Thu Dec 22 12:06:23 2011 +0100
@@ -98,42 +98,59 @@
 
 # TestExecution ################################################################
 
-class TESummaryTable(tableview.TableView):
+class TESummaryTable(EntityView):
     __regid__ = 'apycot.te.summarytable'
     __select__ = is_instance('TestExecution') | none_rset()
-
-    html_headers = no_robot_index
     title = _('Apycot executions')
     category = 'startupview'
 
-    def call(self, showpe=True):
-        self._cw.add_css('cubes.apycot.css')
-        _ = self._cw._
+    html_headers = no_robot_index
+    default_rql = ('Any T,PE,TC,T,TB,TST,TET,TF, TS ORDERBY TST DESC WHERE '
+                   'T status TS, T using_config TC, T using_environment PE, '
+                   'T branch TB, T starttime TST, T endtime TET, T log_file TF?')
+
+    def call(self):
+        w = self.w
+        req = self._cw
         if self.cw_rset is None:
-            assert showpe
-            self.cw_rset = self._cw.execute(
-                'Any T,PE,TC,T,TB,TST,TET,TF, TS ORDERBY TST DESC WHERE '
-                'T status TS, T using_config TC, T using_environment PE, '
-                'T branch TB, T starttime TST, T endtime TET, T log_file TF?')
-            self.w('<h1>%s</h1>' % _(self.title))
-        if showpe:
-            headers = [_('TestExecution'), _('ProjectEnvironment'), _('TestConfig'),
-                       _('checks'), _('branch'),
-                       _('starttime'), _('endtime'), _('archive')]
-            cellvids = {0: 'apycot.te.statuscell',
-                        3: 'apycot.te.summarycell',
-                        7: 'icon'}
-        else:
-            headers = [_('TestExecution'), _('TestConfig'),
-                       _('checks'), _('branch'),
-                       _('starttime'), _('endtime'), _('archive')]
-            cellvids = {0: 'apycot.te.statuscell',
-                        2: 'apycot.te.summarycell',
-                        6: 'icon'}
-        displayfilter = self._cw.form.get('displayfilter', True)
-        super(TESummaryTable, self).call(displayfilter=displayfilter,
-                                         paginate=True,
-                                         headers=headers, cellvids=cellvids)
+            self.cw_rset = req.execute(self.default_rql)
+        self.wview('apycot.te.table', self.cw_rset, 'null')
+
+
+class TETable(tableview.EntityTableView):
+    __regid__ = 'apycot.te.table'
+    __select__ = is_instance('TestExecution')
+
+    columns = ['testexecution', 'projectenvironment', 'using_config', 'checks', 'branch', 'starttime', 'endtime', 'log_file']
+    column_renderers = {
+            'testexecution': tableview.MainEntityColRenderer(
+                vid='apycot.te.statuscell'),
+            'using_config': tableview.RelatedEntityColRenderer(
+                header=_('TestConfig'), getrelated=lambda x: x.configuration),
+            'projectenvironment': tableview.RelatedEntityColRenderer(
+                header=_('ProjectEnvironment'), getrelated=lambda x: x.environment),
+            'checks': tableview.MainEntityColRenderer(
+                header=_('checks'), addcount=False, vid='apycot.te.summarycell'),
+            'log_file': tableview.RelationColRenderer(
+                subvid='icon')
+            }
+    layout_args = {
+            'display_filter': 'top'
+            }
+
+    def call(self, columns=None):
+        self._cw.add_css('cubes.apycot.css')
+        super(TETable, self).call(columns)
+
+
+class TENoPETable(TETable):
+    __regid__ = 'apycot.te.nopetable'
+    columns = ['testexecution', 'using_config', 'checks', 'branch', 'starttime', 'endtime', 'log_file']
+
+
+class TENoTCTable(TETable):
+    __regid__ = 'apycot.te.notctable'
+    columns = ['testexecution', 'projectenvironment', 'checks', 'branch', 'starttime', 'endtime', 'log_file']
 
 
 _pvdc.tag_attribute(('TestExecution', 'priority',), {'vid': 'tasksqueue.priority'}) # XXX rtag inheritance bug
--- a/views/tracker.py	Wed Dec 21 17:52:02 2011 +0100
+++ b/views/tracker.py	Thu Dec 22 12:06:23 2011 +0100
@@ -20,14 +20,14 @@
     __regid__ = title = _('apycottestresults_tab')
     __select__ = is_instance('Project')
 
-    def cell_call(self, row, col):
+    def entity_call(self, entity):
         rset = self._cw.execute(
             'Any T,TC,T,TB,TST,TET,TF, TS ORDERBY TST DESC WHERE '
             'T status TS, T using_config TC, T branch TB, '
             'T starttime TST, T endtime TET, T log_file TF?, '
             'T using_environment PE, P has_apycot_environment PE, '
-            'P eid %(p)s', {'p': self.cw_rset[row][col]})
-        self.wview('apycot.te.summarytable', rset, 'noresult', showpe=False)
+            'P eid %(p)s', {'p': entity.eid})
+        self.wview('apycot.te.nopetable', rset, 'noresult')
 
 
 # class VersionTestResultsVComponent(component.EntityVComponent):