Use TableViewlet base class for scheduler jobs table
authorThierry Florac <thierry.florac@onf.fr>
Fri, 26 Jan 2018 16:33:12 +0100
changeset 46 2200d9093b62
parent 45 f842966dc45d
child 47 a841be26e948
Use TableViewlet base class for scheduler jobs table
src/pyams_scheduler/zmi/scheduler.py
src/pyams_scheduler/zmi/templates/scheduler-jobs.pt
--- a/src/pyams_scheduler/zmi/scheduler.py	Sun Jan 14 14:50:37 2018 +0100
+++ b/src/pyams_scheduler/zmi/scheduler.py	Fri Jan 26 16:33:12 2018 +0100
@@ -9,11 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from pyams_form.schema import CloseButton
-from pyams_skin.interfaces.viewlet import ITableItemColumnActionsMenu
-from pyams_skin.viewlet.toolbar import ToolbarMenuItem
-from pyams_utils.text import text_to_html
-from pyams_zmi.control_panel import UtilitiesTable
 
 __docformat__ = 'restructuredtext'
 
@@ -30,6 +25,7 @@
 from pyams_scheduler.zmi.interfaces import ISchedulerMenu
 from pyams_skin.interfaces import IInnerPage, IPageHeader
 from pyams_skin.interfaces.container import ITableElementEditor
+from pyams_skin.interfaces.viewlet import ITableItemColumnActionsMenu
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import MANAGE_SYSTEM_PERMISSION
 from pyams_zmi.interfaces.menu import IControlPanelMenu
@@ -39,19 +35,23 @@
 
 # import packages
 from pyams_form.form import AJAXEditForm, AJAXAddForm
+from pyams_form.schema import CloseButton
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.container import ContainerView
 from pyams_skin.page import DefaultPageHeaderAdapter
-from pyams_skin.table import DefaultElementEditorAdapter, BaseTable, I18nColumn, TrashColumn, ActionColumn
+from pyams_skin.table import DefaultElementEditorAdapter, BaseTable, I18nColumn, TrashColumn, ActionColumn, TableViewlet
 from pyams_skin.viewlet.menu import MenuItem
+from pyams_skin.viewlet.toolbar import ToolbarMenuItem
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
 from pyams_utils.date import format_datetime
 from pyams_utils.registry import query_utility
+from pyams_utils.text import text_to_html
 from pyams_utils.traversing import get_parent
 from pyams_utils.url import absolute_url
 from pyams_viewlet.manager import viewletmanager_config
 from pyams_viewlet.viewlet import viewlet_config, Viewlet
+from pyams_zmi.control_panel import UtilitiesTable
 from pyams_zmi.form import AdminDialogEditForm, AdminDialogDisplayForm, AdminDialogAddForm
 from pyams_zmi.view import AdminView
 from pyams_zmq.socket import zmq_socket, zmq_response
@@ -392,19 +392,10 @@
 
 @viewlet_config(name='scheduler-jobs', view=SchedulerJobsDisplayForm, layer=IAdminLayer,
                 manager=IWidgetsSuffixViewletsManager)
-@template_config(template='templates/scheduler-jobs.pt')
-class SchedulerJobsViewlet(Viewlet):
+class SchedulerJobsViewlet(TableViewlet):
     """Scheduler jobs viewlet"""
 
-    table = SchedulerJobsTable
-
-    def __init__(self, context, request, view, manager):
-        super(SchedulerJobsViewlet, self).__init__(context, request, view, manager)
-        self.table = SchedulerJobsTable(context, request)
-
-    def update(self):
-        super(SchedulerJobsViewlet, self).update()
-        self.table.update()
+    table_class = SchedulerJobsTable
 
 
 @viewlet_config(name='test-scheduler-process.menu', context=IScheduler, layer=IAdminLayer,
--- a/src/pyams_scheduler/zmi/templates/scheduler-jobs.pt	Sun Jan 14 14:50:37 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-<div class="no-widget-toolbar">
-	<tal:var replace="structure view.table.render()" />
-</div>