Set selected workflow to display mode except for system administrator
authorThierry Florac <thierry.florac@onf.fr>
Tue, 05 Jun 2018 17:35:02 +0200
changeset 582 e73547789571
parent 581 e8befd0dd932
child 583 a3df1b69616b
Set selected workflow to display mode except for system administrator
src/pyams_content/shared/common/zmi/manager.py
--- a/src/pyams_content/shared/common/zmi/manager.py	Tue Jun 05 17:05:17 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/manager.py	Tue Jun 05 17:35:02 2018 +0200
@@ -23,9 +23,11 @@
 from pyams_skin.interfaces import IInnerPage, IPageHeader, IContentTitle
 from pyams_skin.interfaces.viewlet import IMenuHeader, IBreadcrumbItem
 from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import MANAGE_SYSTEM_PERMISSION
 from pyams_zmi.interfaces import IPropertiesEditForm
 from pyams_zmi.interfaces.menu import IPropertiesMenu, ISiteManagementMenu
 from pyams_zmi.layer import IAdminLayer
+from z3c.form.interfaces import DISPLAY_MODE
 
 # import packages
 from pyams_form.form import AJAXEditForm
@@ -109,6 +111,11 @@
     ajax_handler = 'properties.json'
     edit_permission = MANAGE_TOOL_PERMISSION
 
+    def updateWidgets(self, prefix=None):
+        super(SharedToolPropertiesEditForm, self).updateWidgets(prefix)
+        if not self.request.has_permission(MANAGE_SYSTEM_PERMISSION, context=self.context):
+            self.widgets['shared_content_workflow'].mode = DISPLAY_MODE
+
 
 @view_config(name='properties.json', context=IBaseSharedTool, request_type=IPyAMSLayer,
              permission=MANAGE_TOOL_PERMISSION, renderer='json', xhr=True)