# HG changeset patch # User Thierry Florac # Date 1507878424 -7200 # Node ID 07dc3a8e34f745500dcb8bf7aec0f787b1dee87a # Parent cd56db960a5d16e991e3fa4ae2c5fac30dd3c311 Added help and permission checker for languages update form diff -r cd56db960a5d -r 07dc3a8e34f7 src/pyams_i18n/zmi/language.py --- a/src/pyams_i18n/zmi/language.py Fri Oct 13 09:06:29 2017 +0200 +++ b/src/pyams_i18n/zmi/language.py Fri Oct 13 09:07:04 2017 +0200 @@ -16,7 +16,7 @@ # import standard library # import interfaces -from pyams_form.interfaces.form import IWidgetForm +from pyams_form.interfaces.form import IWidgetForm, IFormHelp, IFormContextPermissionChecker from pyams_i18n.interfaces import II18nManager from pyams_skin.interfaces import IInnerPage from pyams_skin.layer import IPyAMSLayer @@ -26,8 +26,10 @@ # import packages from pyams_form.form import AJAXEditForm +from pyams_form.help import FormHelp from pyams_pagelet.pagelet import pagelet_config from pyams_skin.viewlet.menu import MenuItem +from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter from pyams_viewlet.viewlet import viewlet_config from pyams_zmi.form import AdminEditForm from pyramid.view import view_config @@ -61,10 +63,28 @@ fields = field.Fields(II18nManager) ajax_handler = 'languages.json' - edit_permission = MANAGE_PERMISSION + edit_permission = None @view_config(name='languages.json', context=II18nManager, request_type=IPyAMSLayer, - permission=MANAGE_PERMISSION, renderer='json', xhr=True) + permission=VIEW_SYSTEM_PERMISSION, renderer='json', xhr=True) class I18nManagerLanguagesAJAXEditForm(AJAXEditForm, I18nManagerLanguagesEditForm): """I18n manager languages edit form, JSON renderer""" + + +@adapter_config(context=(II18nManager, IPyAMSLayer, I18nManagerLanguagesEditForm), provides=IFormHelp) +class I18nManagerLanguageEditFormHelp(FormHelp): + """I18n manager language edit form help adapter""" + + outer_margin = 10 + message = _("For each selected language, a tab will be associated to each form input to enter matching " + "translation.") + message_format = 'rest' + + +@adapter_config(context=(II18nManager, IPyAMSLayer, I18nManagerLanguagesEditForm), + provides=IFormContextPermissionChecker) +class I18nManagerLanguageEditFormPermissionChecker(ContextRequestViewAdapter): + """I18n manager language edit form permission checker""" + + edit_permission = MANAGE_PERMISSION