Reload tasks list on 'active' field update
authorThierry Florac <tflorac@ulthar.net>
Wed, 11 Mar 2015 21:30:17 +0100
changeset 3 13a265dc6051
parent 2 7b56f247a0c4
child 4 03b9d3744d75
Reload tasks list on 'active' field update
src/pyams_scheduler/zmi/task.py
--- a/src/pyams_scheduler/zmi/task.py	Wed Mar 11 17:16:21 2015 +0100
+++ b/src/pyams_scheduler/zmi/task.py	Wed Mar 11 21:30:17 2015 +0100
@@ -18,7 +18,7 @@
 # import interfaces
 from pyams_form.interfaces.form import IWidgetsSuffixViewletsManager, IWidgetsPrefixViewletsManager
 from pyams_scheduler.interfaces import ITaskInfo, IScheduler, ITask, ICronTask, ICronTaskScheduling, IDateTask, \
-    IDateTaskScheduling, ILoopTask, ILoopTaskScheduling, ITaskHistory
+    IDateTaskScheduling, ILoopTask, ILoopTaskScheduling, ITaskHistory, IBaseTaskScheduling
 from pyams_skin.interfaces import IContentHelp
 from pyams_skin.layer import IPyAMSLayer
 from pyams_zmi.layer import IAdminLayer
@@ -158,6 +158,12 @@
 class CronTaskScheduleAJAXEditForm(AJAXEditForm, CronTaskScheduleEditForm):
     """Cron-style task schedule edit form, AJAX view"""
 
+    def get_ajax_output(self, changes):
+        if 'active' in changes.get(IBaseTaskScheduling, ()):
+            return {'status': 'reload'}
+        else:
+            return super(CronTaskScheduleAJAXEditForm, self).get_ajax_output(changes)
+
 
 @pagelet_config(name='schedule.html', context=IDateTask, layer=IPyAMSLayer, permission='system.view')
 class DateTaskScheduleEditForm(TaskScheduleEditForm):
@@ -171,6 +177,12 @@
 class DateTaskScheduleAJAXEditForm(AJAXEditForm, DateTaskScheduleEditForm):
     """Date-style task schedule edit form, AJAX view"""
 
+    def get_ajax_output(self, changes):
+        if 'active' in changes.get(IBaseTaskScheduling, ()):
+            return {'status': 'reload'}
+        else:
+            return super(DateTaskScheduleAJAXEditForm, self).get_ajax_output(changes)
+
 
 @pagelet_config(name='schedule.html', context=ILoopTask, layer=IPyAMSLayer, permission='system.view')
 class LoopTaskScheduleEditForm(TaskScheduleEditForm):
@@ -184,6 +196,12 @@
 class LoopTaskScheduleAJAXEditForm(AJAXEditForm, LoopTaskScheduleEditForm):
     """Loop-style task schedule edit form, AJAX view"""
 
+    def get_ajax_output(self, changes):
+        if 'active' in changes.get(IBaseTaskScheduling, ()):
+            return {'status': 'reload'}
+        else:
+            return super(LoopTaskScheduleAJAXEditForm, self).get_ajax_output(changes)
+
 
 class ITaskRunnerButtons(Interface):
     """Task runner buttons"""