Updated permissions for languages settings
authorThierry Florac <thierry.florac@onf.fr>
Fri, 13 Oct 2017 08:37:23 +0200
changeset 223 9611e89681dc
parent 222 178dd0dd970c
child 224 fcac7810b9d6
Updated permissions for languages settings
src/pyams_content/shared/common/zmi/i18n.py
src/pyams_content/shared/common/zmi/manager.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/common/zmi/i18n.py	Fri Oct 13 08:37:23 2017 +0200
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
+from pyams_content.shared.common.interfaces import IWfSharedContent
+from pyams_form.interfaces.form import IFormContextPermissionChecker
+from pyams_skin.layer import IPyAMSLayer
+
+# import packages
+from pyams_i18n.zmi.language import I18nManagerLanguagesEditForm
+from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
+
+
+@adapter_config(context=(IWfSharedContent, IPyAMSLayer, I18nManagerLanguagesEditForm),
+                provides=IFormContextPermissionChecker)
+class SharedContentLanguageEditFormPermissionChecker(ContextRequestViewAdapter):
+    """I18n manager language edit form permission checker"""
+
+    edit_permission = MANAGE_CONTENT_PERMISSION
--- a/src/pyams_content/shared/common/zmi/manager.py	Fri Oct 13 08:36:16 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/manager.py	Fri Oct 13 08:37:23 2017 +0200
@@ -137,7 +137,18 @@
 # Shared tool languages
 #
 
-@pagelet_config(name='languages.html', context=ISharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
+@viewlet_config(name='languages.menu', context=ISharedTool, layer=IAdminLayer,
+                manager=ISiteManagementMenu, permission=MANAGE_TOOL_PERMISSION, weight=10)
+class SharedToolLanguagesMenu(MenuItem):
+    """Shared tool languages menu"""
+
+    label = _("Languages")
+    icon_class = 'fa-flag'
+
+    url = '#languages.html'
+
+
+@pagelet_config(name='languages.html', context=ISharedTool, layer=IPyAMSLayer, permission=MANAGE_TOOL_PERMISSION)
 @implementer(IInnerPage, IWidgetForm)
 class SharedToolLanguagesEditForm(AdminEditForm):
     """Shared tool languages edit form"""