Created base AJAX task schedule form
authorThierry Florac <thierry.florac@onf.fr>
Thu, 12 Mar 2015 09:06:19 +0100
changeset 4 03b9d3744d75
parent 3 13a265dc6051
child 5 0fe262326e0e
Created base AJAX task schedule form
src/pyams_scheduler/zmi/task.py
--- a/src/pyams_scheduler/zmi/task.py	Wed Mar 11 21:30:17 2015 +0100
+++ b/src/pyams_scheduler/zmi/task.py	Thu Mar 12 09:06:19 2015 +0100
@@ -146,6 +146,16 @@
         return changes
 
 
+class TaskSchedulerAJAXEditForm(AJAXEditForm):
+    """Scheduler task base schedule edit form, AJAX view"""
+
+    def get_ajax_output(self, changes):
+        if 'active' in changes.get(IBaseTaskScheduling, ()):
+            return {'status': 'reload'}
+        else:
+            return super(TaskSchedulerAJAXEditForm, self).get_ajax_output(changes)
+
+
 @pagelet_config(name='schedule.html', context=ICronTask, layer=IPyAMSLayer, permission='system.view')
 class CronTaskScheduleEditForm(TaskScheduleEditForm):
     """Cron-style task schedule edit form"""
@@ -155,15 +165,9 @@
 
 @view_config(name='schedule.json', context=ICronTask, request_type=IPyAMSLayer,
              permission='system.manage', renderer='json', xhr=True)
-class CronTaskScheduleAJAXEditForm(AJAXEditForm, CronTaskScheduleEditForm):
+class CronTaskScheduleAJAXEditForm(TaskSchedulerAJAXEditForm, 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):
@@ -174,15 +178,9 @@
 
 @view_config(name='schedule.json', context=IDateTask, request_type=IPyAMSLayer,
              permission='system.manage', renderer='json', xhr=True)
-class DateTaskScheduleAJAXEditForm(AJAXEditForm, DateTaskScheduleEditForm):
+class DateTaskScheduleAJAXEditForm(TaskSchedulerAJAXEditForm, 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):
@@ -193,15 +191,9 @@
 
 @view_config(name='schedule.json', context=ILoopTask, request_type=IPyAMSLayer,
              permission='system.manage', renderer='json', xhr=True)
-class LoopTaskScheduleAJAXEditForm(AJAXEditForm, LoopTaskScheduleEditForm):
+class LoopTaskScheduleAJAXEditForm(TaskSchedulerAJAXEditForm, 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"""