Updated permission to access form fields edit form
authorThierry Florac <tflorac@ulthar.net>
Tue, 23 Jun 2020 11:33:58 +0200
changeset 1386 6ea367aeb03c
parent 1385 7383e6ce5411
child 1387 6eb6e88e3365
Updated permission to access form fields edit form
src/pyams_content/shared/form/zmi/field.py
--- a/src/pyams_content/shared/form/zmi/field.py	Mon Jun 22 17:34:24 2020 +0200
+++ b/src/pyams_content/shared/form/zmi/field.py	Tue Jun 23 11:33:58 2020 +0200
@@ -25,8 +25,8 @@
 from pyams_content.shared.common.interfaces import IWfSharedContent
 from pyams_content.shared.common.zmi import WfModifiedContentColumnMixin
 from pyams_content.shared.form.field import FormField
-from pyams_content.shared.form.interfaces import IFormField, IFormFieldContainer, IFormFieldContainerTarget, \
-    IFormFieldFactory
+from pyams_content.shared.form.interfaces import IFormField, IFormFieldContainer, \
+    IFormFieldContainerTarget, IFormFieldFactory
 from pyams_content.zmi import pyams_content
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_form.interfaces.form import IFormSecurityContext
@@ -38,7 +38,8 @@
 from pyams_skin.interfaces.container import ITableWithActions
 from pyams_skin.interfaces.viewlet import IWidgetTitleViewletManager
 from pyams_skin.layer import IPyAMSLayer
-from pyams_skin.table import BaseTable, I18nColumn, I18nValueColumn, SorterColumn, TrashColumn, VisibilitySwitcherColumn
+from pyams_skin.table import BaseTable, I18nColumn, I18nValueColumn, SorterColumn, TrashColumn, \
+    VisibilitySwitcherColumn
 from pyams_skin.viewlet.menu import MenuItem
 from pyams_skin.viewlet.toolbar import ToolbarAction
 from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
@@ -122,20 +123,23 @@
         return super(FormFieldsContainerTable, self).render()
 
 
-@adapter_config(name='sorter', context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldsContainerTable),
+@adapter_config(name='sorter', context=(IFormFieldContainerTarget, IPyAMSLayer,
+                                        FormFieldsContainerTable),
                 provides=IColumn)
 class FormFieldsContainerSorterColumn(ProtectedFormObjectMixin, SorterColumn):
     """Form fields container sorter column"""
 
 
-@adapter_config(name='show-hide', context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldsContainerTable),
+@adapter_config(name='show-hide', context=(IFormFieldContainerTarget, IPyAMSLayer,
+                                           FormFieldsContainerTable),
                 provides=IColumn)
 class FormFieldsContainerShowHideColumn(ProtectedFormObjectMixin, VisibilitySwitcherColumn):
     """Form fields container visibility switcher column"""
 
 
-@view_config(name='switch-form-field-visibility.json', context=IFormFieldContainer, request_type=IPyAMSLayer,
-             permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
+@view_config(name='switch-form-field-visibility.json', context=IFormFieldContainer,
+             request_type=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION,
+             renderer='json', xhr=True)
 def switch_form_field_visibility(request):
     """Set form field visibility"""
     return switch_element_visibility(request, IFormFieldContainer)
@@ -147,7 +151,8 @@
     return column.table.context
 
 
-@adapter_config(name='name', context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldsContainerTable),
+@adapter_config(name='name', context=(IFormFieldContainerTarget, IPyAMSLayer,
+                                      FormFieldsContainerTable),
                 provides=IColumn)
 class FormFieldsContainerNameColumn(I18nColumn, WfModifiedContentColumnMixin, GetAttrColumn):
     """Form fields container name column"""
@@ -158,7 +163,8 @@
     weight = 50
 
 
-@adapter_config(name='label', context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldsContainerTable),
+@adapter_config(name='label', context=(IFormFieldContainerTarget, IPyAMSLayer,
+                                       FormFieldsContainerTable),
                 provides=IColumn)
 class FormFieldsContainerLabelColumn(I18nColumn, WfModifiedContentColumnMixin, I18nValueColumn):
     """Form fields container label column"""
@@ -169,7 +175,8 @@
     weight = 55
 
 
-@adapter_config(name='type', context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldsContainerTable),
+@adapter_config(name='type', context=(IFormFieldContainerTarget, IPyAMSLayer,
+                                      FormFieldsContainerTable),
                 provides=IColumn)
 class FormFieldsContainerTypeColumn(I18nColumn, WfModifiedContentColumnMixin, GetAttrColumn):
     """Form fields container label column"""
@@ -187,13 +194,15 @@
         return self.request.localizer.translate(label)
 
 
-@adapter_config(name='trash', context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldsContainerTable),
+@adapter_config(name='trash', context=(IFormFieldContainerTarget, IPyAMSLayer,
+                                       FormFieldsContainerTable),
                 provides=IColumn)
 class FormFieldsContainerTrashColumn(ProtectedFormObjectMixin, TrashColumn):
     """Form fields container trash column"""
 
 
-@adapter_config(context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldsContainerTable), provides=IValues)
+@adapter_config(context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldsContainerTable),
+                provides=IValues)
 class FormFieldsContainerValues(ContextRequestViewAdapter):
     """Form fields container values"""
 
@@ -211,8 +220,9 @@
     table_class = FormFieldsContainerTable
 
 
-@view_config(name='set-form-fields-order.json', context=IFormFieldContainer, request_type=IPyAMSLayer,
-             permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
+@view_config(name='set-form-fields-order.json', context=IFormFieldContainer,
+             request_type=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION,
+             renderer='json', xhr=True)
 def set_form_fields_order(request):
     """Update form fields order"""
     order = list(map(str, json.loads(request.params.get('names'))))
@@ -269,7 +279,8 @@
     event.data['name'] = name
 
 
-@pagelet_config(name='properties.html', context=IFormField, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION)
+@pagelet_config(name='properties.html', context=IFormField, layer=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
 @ajax_config(name='properties.json', context=IFormField, layer=IPyAMSLayer)
 class FormFieldPropertiesEditForm(AdminDialogEditForm):
     """Form field properties edit form"""
@@ -297,5 +308,6 @@
         if changes:
             container = get_parent(self.context, IFormFieldContainerTarget)
             output.setdefault('events', []).append(
-                get_json_table_row_refresh_event(container, self.request, FormFieldsContainerTable, self.context))
+                get_json_table_row_refresh_event(container, self.request,
+                                                 FormFieldsContainerTable, self.context))
         return output