--- a/src/pyams_scheduler/zmi/scheduler.py Wed Mar 28 16:02:34 2018 +0200
+++ b/src/pyams_scheduler/zmi/scheduler.py Wed Apr 11 11:37:21 2018 +0200
@@ -37,7 +37,7 @@
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.container import ContainerView, delete_container_element
from pyams_skin.page import DefaultPageHeaderAdapter
from pyams_skin.table import DefaultElementEditorAdapter, BaseTable, I18nColumn, TrashColumn, ActionColumn, TableViewlet
from pyams_skin.viewlet.menu import MenuItem
@@ -99,12 +99,9 @@
def data_attributes(self):
manager = query_utility(IScheduler)
attributes = super(SchedulerTasksTable, self).data_attributes
- table_attrs = {'data-ams-location': absolute_url(manager, self.request),
- 'data-ams-delete-target': 'delete-task.json'}
- if 'table' in attributes:
- attributes['table'].update(table_attrs)
- else:
- attributes['table'] = table_attrs
+ attributes.setdefault('table', {}).update({
+ 'data-ams-location': absolute_url(manager, self.request)
+ })
return attributes
def getCSSHighlightClass(self, column, item, cssClass):
@@ -198,22 +195,11 @@
permission = MANAGE_SYSTEM_PERMISSION
-@view_config(name='delete-task.json', context=IScheduler, request_type=IPyAMSLayer,
+@view_config(name='delete-element.json', context=IScheduler, request_type=IPyAMSLayer,
permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
def delete_scheduler_task(request):
"""Delete task from scheduler utility"""
- translate = request.localizer.translate
- name = request.params.get('object_name')
- if not name:
- return {'status': 'message',
- 'messagebox': {'status': 'error',
- 'content': translate(_("No provided object_name argument!"))}}
- if name not in request.context:
- return {'status': 'message',
- 'messagebox': {'status': 'error',
- 'content': translate(_("Given task name doesn't exist!"))}}
- del request.context[name]
- return {'status': 'success'}
+ return delete_container_element(request, ignore_permission=True)
@adapter_config(context=(ISite, IAdminLayer, SchedulerTasksTable), provides=IValues)
@@ -265,6 +251,8 @@
class SchedulerPropertiesEditForm(AdminDialogEditForm):
"""Scheduler properties edit form"""
+ prefix = 'scheduler_properties.'
+
@property
def title(self):
return self.context.__name__
@@ -319,11 +307,15 @@
@property
def data_attributes(self):
- return {'table': {'data-ams-datatable-global-filter': 'false',
- 'data-ams-datatable-info': 'false',
- 'data-ams-datatable-sdom': "t<'dt-row dt-bottom-row'<'text-right'p>>",
- 'data-ams-datatable-display-length': '20',
- 'data-ams-datatable-pagination-type': 'bootstrap_prevnext'}}
+ return {
+ 'table': {
+ 'data-ams-datatable-global-filter': 'false',
+ 'data-ams-datatable-info': 'false',
+ 'data-ams-datatable-sdom': "t<'dt-row dt-bottom-row'<'text-right'p>>",
+ 'data-ams-datatable-display-length': '20',
+ 'data-ams-datatable-pagination-type': 'bootstrap_prevnext'
+ }
+ }
@adapter_config(name='name', context=(Interface, IAdminLayer, SchedulerJobsTable), provides=IColumn)
@@ -456,10 +448,18 @@
def get_ajax_output(self, changes):
status, message = changes
if status == 200:
- return {'status': 'success',
- 'content': {'html': text_to_html(message)},
- 'close_form': False}
+ return {
+ 'status': 'success',
+ 'content': {
+ 'html': text_to_html(message)
+ },
+ 'close_form': False
+ }
else:
- return {'status': 'info',
- 'content': {'html': text_to_html(message)},
- 'close_form': False}
+ return {
+ 'status': 'info',
+ 'content': {
+ 'html': text_to_html(message)
+ },
+ 'close_form': False
+ }
--- a/src/pyams_scheduler/zmi/ssh.py Wed Mar 28 16:02:34 2018 +0200
+++ b/src/pyams_scheduler/zmi/ssh.py Wed Apr 11 11:37:21 2018 +0200
@@ -71,6 +71,8 @@
class SSHTaskEditForm(AdminDialogEditForm):
"""SSH command task edit form"""
+ prefix = 'ssh_settings.'
+
@property
def title(self):
translate = self.request.localizer.translate
--- a/src/pyams_scheduler/zmi/task.py Wed Mar 28 16:02:34 2018 +0200
+++ b/src/pyams_scheduler/zmi/task.py Wed Apr 11 11:37:21 2018 +0200
@@ -98,6 +98,8 @@
class TaskPropertiesEditForm(AdminDialogEditForm):
"""Scheduler task properties edit form"""
+ prefix = 'task_properties.'
+
@property
def title(self):
translate = self.request.localizer.translate
@@ -126,6 +128,8 @@
class TaskScheduleEditForm(AdminDialogEditForm):
"""Scheduler task base schedule edit form"""
+ prefix = 'task_schedule.'
+
@property
def title(self):
translate = self.request.localizer.translate
@@ -207,6 +211,8 @@
class TaskRunForm(AdminDialogEditForm):
"""Task runner form"""
+ prefix = 'task_run.'
+
@property
def title(self):
translate = self.request.localizer.translate
@@ -244,15 +250,21 @@
def get_ajax_output(self, changes):
translate = self.request.localizer.translate
if self.actions['execute'].name in self.request.params:
- return {'status': 'success',
- 'message': translate(_('Task scheduled in normal mode will start in 5 seconds...'))}
+ return {
+ 'status': 'success',
+ 'message': translate(_('Task scheduled in normal mode will start in 5 seconds...'))
+ }
else:
- return {'status': 'message',
- 'content': {'raw': True,
- 'text': changes,
- 'target': '#task-debug-report'},
- 'message': translate(_('Task run in debug mode. Please check your console...')),
- 'close_form': False}
+ return {
+ 'status': 'message',
+ 'content': {
+ 'raw': True,
+ 'text': changes,
+ 'target': '#task-debug-report'
+ },
+ 'message': translate(_('Task run in debug mode. Please check your console...')),
+ 'close_form': False
+ }
@adapter_config(context=(ITask, IAdminLayer, TaskRunForm), provides=IFormHelp)
@@ -310,14 +322,19 @@
@property
def data_attributes(self):
- return {'table': {'data-ams-datatable-global-filter': 'false',
- 'data-ams-datatable-info': 'false',
- 'data-ams-datatable-sort': 'false',
- 'data-ams-datatable-sdom': "t<'dt-row dt-bottom-row'<'text-right'p>>",
- 'data-ams-datatable-display-length': '20',
- 'data-ams-datatable-pagination-type': 'bootstrap_prevnext'},
- 'tr': {'data-ams-url': lambda x, col: absolute_url(x, self.request, 'info.json'),
- 'data-ams-target': '#task-history-report'}}
+ return {
+ 'table': {
+ 'data-ams-datatable-global-filter': 'false',
+ 'data-ams-datatable-info': 'false',
+ 'data-ams-datatable-sort': 'false',
+ 'data-ams-datatable-sdom': "t<'dt-row dt-bottom-row'<'text-right'p>>",
+ 'data-ams-datatable-display-length': '20',
+ 'data-ams-datatable-pagination-type': 'bootstrap_prevnext'},
+ 'tr': {
+ 'data-ams-url': lambda x, col: absolute_url(x, self.request, 'info.json'),
+ 'data-ams-target': '#task-history-report'
+ }
+ }
def getCSSHighlightClass(self, column, item, cssClass):
return STATUS_CLASS[item.status]
@@ -365,8 +382,12 @@
@view_config(name='info.json', context=ITaskHistory, request_type=IPyAMSLayer,
permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
def TaskHistoryInfoView(request):
- return {'status': 'success',
- 'close_form': False,
- 'content': {'raw': True,
- 'text': request.context.report,
- 'target': '#task-history-report'}}
+ return {
+ 'status': 'success',
+ 'close_form': False,
+ 'content': {
+ 'raw': True,
+ 'text': request.context.report,
+ 'target': '#task-history-report'
+ }
+ }
--- a/src/pyams_scheduler/zmi/url.py Wed Mar 28 16:02:34 2018 +0200
+++ b/src/pyams_scheduler/zmi/url.py Wed Apr 11 11:37:21 2018 +0200
@@ -71,6 +71,8 @@
class URLTaskEditForm(AdminDialogEditForm):
"""URL caller task edit form"""
+ prefix = 'url_settings.'
+
@property
def title(self):
translate = self.request.localizer.translate
--- a/src/pyams_scheduler/zmi/zodb.py Wed Mar 28 16:02:34 2018 +0200
+++ b/src/pyams_scheduler/zmi/zodb.py Wed Apr 11 11:37:21 2018 +0200
@@ -71,6 +71,8 @@
class ZODBTaskEditForm(AdminDialogEditForm):
"""ZODB packing task edit form"""
+ prefix = 'zodb_settings.'
+
@property
def title(self):
translate = self.request.localizer.translate