17 |
17 |
18 # import interfaces |
18 # import interfaces |
19 from pyams_scheduler.interfaces.zodb import IZODBPackingTask, IZODBPackingTaskInfo |
19 from pyams_scheduler.interfaces.zodb import IZODBPackingTask, IZODBPackingTaskInfo |
20 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu |
20 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu |
21 from pyams_skin.layer import IPyAMSLayer |
21 from pyams_skin.layer import IPyAMSLayer |
|
22 from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION, MANAGE_SYSTEM_PERMISSION |
22 from zope.component.interfaces import ISite |
23 from zope.component.interfaces import ISite |
23 |
24 |
24 # import packages |
25 # import packages |
25 from pyams_form.form import AJAXAddForm, AJAXEditForm |
26 from pyams_form.form import AJAXAddForm, AJAXEditForm |
26 from pyams_pagelet.pagelet import pagelet_config |
27 from pyams_pagelet.pagelet import pagelet_config |
36 from pyams_scheduler import _ |
37 from pyams_scheduler import _ |
37 |
38 |
38 |
39 |
39 @viewlet_config(name='add-scheduler-zodb-task.menu', context=ISite, layer=IPyAMSLayer, |
40 @viewlet_config(name='add-scheduler-zodb-task.menu', context=ISite, layer=IPyAMSLayer, |
40 view=SchedulerTasksTable, manager=IToolbarAddingMenu, |
41 view=SchedulerTasksTable, manager=IToolbarAddingMenu, |
41 permission='system.manage', weight=5) |
42 permission=MANAGE_SYSTEM_PERMISSION, weight=5) |
42 class ZODBTaskAddMenu(ToolbarMenuItem): |
43 class ZODBTaskAddMenu(ToolbarMenuItem): |
43 """ZODB packing task add menu""" |
44 """ZODB packing task add menu""" |
44 |
45 |
45 label = _("Add ZODB packing task...") |
46 label = _("Add ZODB packing task...") |
46 label_css_class = 'fa fa-fw fa-database' |
47 label_css_class = 'fa fa-fw fa-database' |
47 url = 'add-scheduler-zodb-task.html' |
48 url = 'add-scheduler-zodb-task.html' |
48 modal_target = True |
49 modal_target = True |
49 |
50 |
50 |
51 |
51 @pagelet_config(name='add-scheduler-zodb-task.html', context=ISite, layer=IPyAMSLayer, |
52 @pagelet_config(name='add-scheduler-zodb-task.html', context=ISite, layer=IPyAMSLayer, |
52 permission='system.manage') |
53 permission=MANAGE_SYSTEM_PERMISSION) |
53 class ZODBTaskAddForm(TaskBaseAddForm): |
54 class ZODBTaskAddForm(TaskBaseAddForm): |
54 """ZODB packing task add form""" |
55 """ZODB packing task add form""" |
55 |
56 |
56 legend = _("Add ZODB packing task") |
57 legend = _("Add ZODB packing task") |
57 icon_css_class = 'fa fa-fw fa-database' |
58 icon_css_class = 'fa fa-fw fa-database' |
59 ajax_handler = 'add-scheduler-zodb-task.json' |
60 ajax_handler = 'add-scheduler-zodb-task.json' |
60 task_factory = ZODBPackingTask |
61 task_factory = ZODBPackingTask |
61 |
62 |
62 |
63 |
63 @view_config(name='add-scheduler-zodb-task.json', context=ISite, request_type=IPyAMSLayer, |
64 @view_config(name='add-scheduler-zodb-task.json', context=ISite, request_type=IPyAMSLayer, |
64 permission='system.manage', renderer='json', xhr=True) |
65 permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True) |
65 class ZODBTaskAJAXAddForm(AJAXAddForm, ZODBTaskAddForm): |
66 class ZODBTaskAJAXAddForm(AJAXAddForm, ZODBTaskAddForm): |
66 """ZODB packing task add form, AJAX view""" |
67 """ZODB packing task add form, AJAX view""" |
67 |
68 |
68 |
69 |
69 @pagelet_config(name='settings.html', context=IZODBPackingTask, layer=IPyAMSLayer, permission='system.view') |
70 @pagelet_config(name='settings.html', context=IZODBPackingTask, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
70 class ZODBTaskEditForm(AdminDialogEditForm): |
71 class ZODBTaskEditForm(AdminDialogEditForm): |
71 """ZODB packing task edit form""" |
72 """ZODB packing task edit form""" |
72 |
73 |
73 @property |
74 @property |
74 def title(self): |
75 def title(self): |
78 legend = _("Edit task settings") |
79 legend = _("Edit task settings") |
79 icon_css_class = 'fa fa-fw fa-database' |
80 icon_css_class = 'fa fa-fw fa-database' |
80 |
81 |
81 fields = field.Fields(IZODBPackingTaskInfo) |
82 fields = field.Fields(IZODBPackingTaskInfo) |
82 ajax_handler = 'settings.json' |
83 ajax_handler = 'settings.json' |
83 edit_permission = 'system.manage' |
84 edit_permission = MANAGE_SYSTEM_PERMISSION |
84 |
85 |
85 |
86 |
86 @view_config(name='settings.json', context=IZODBPackingTask, request_type=IPyAMSLayer, |
87 @view_config(name='settings.json', context=IZODBPackingTask, request_type=IPyAMSLayer, |
87 permission='system.manage', renderer='json', xhr=True) |
88 permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True) |
88 class ZODBTaskAJAXEditForm(AJAXEditForm, ZODBTaskEditForm): |
89 class ZODBTaskAJAXEditForm(AJAXEditForm, ZODBTaskEditForm): |
89 """ZODB packing task edit form, AJAX view""" |
90 """ZODB packing task edit form, AJAX view""" |