# HG changeset patch # User Damien Correia # Date 1529937212 -7200 # Node ID d6548428279d633e24157df734e46556436b7bfd # Parent 046189ebbbd0592c6e8f889b508107fb2170e70e# Parent b4e70a25236ac6b836d39cdb30fc6e1f0c8b194a merge default diff -r b4e70a25236a -r d6548428279d src/pyams_content/component/keynumber/__init__.py --- a/src/pyams_content/component/keynumber/__init__.py Mon Jun 25 16:28:17 2018 +0200 +++ b/src/pyams_content/component/keynumber/__init__.py Mon Jun 25 16:33:32 2018 +0200 @@ -10,7 +10,6 @@ # FOR A PARTICULAR PURPOSE. # - __docformat__ = 'restructuredtext' @@ -157,6 +156,16 @@ name='++keynumbers++') +@adapter_config(context=IKeyNumberContainer, provides=IFormContextPermissionChecker) +class KeyNumberContainerPermissionChecker(ContextAdapter): + """Key number container permission checker""" + + @property + def edit_permission(self): + content = get_parent(self.context, IKeyNumberContainerTarget) + return IFormContextPermissionChecker(content).edit_permission + + @adapter_config(name='keynumbers', context=IKeyNumberContainerTarget, provides=ITraversable) class KeyNumberContainerNamespace(ContextAdapter): """Key numbers container ++keynumbers++ namespace""" diff -r b4e70a25236a -r d6548428279d src/pyams_content/component/keynumber/zmi/__init__.py --- a/src/pyams_content/component/keynumber/zmi/__init__.py Mon Jun 25 16:28:17 2018 +0200 +++ b/src/pyams_content/component/keynumber/zmi/__init__.py Mon Jun 25 16:33:32 2018 +0200 @@ -210,8 +210,8 @@ # @viewlet_config(name='add-keynumber.action', context=IKeyNumberContainerTarget, layer=IPyAMSLayer, view=IKeyNumbersView, - manager=IWidgetTitleViewletManager, permission=MANAGE_CONTENT_PERMISSION, weight=1) -class KeyNumberAddAction(ToolbarAction): + manager=IWidgetTitleViewletManager, weight=1) +class KeyNumberAddAction(ProtectedFormObjectMixin, ToolbarAction): """Key number add action""" label = _("Add keynumber") @@ -220,8 +220,7 @@ modal_target = True -@pagelet_config(name='add-keynumber.html', context=IKeyNumberContainer, layer=IPyAMSLayer, - permission=MANAGE_CONTENT_PERMISSION) +@pagelet_config(name='add-keynumber.html', context=IKeyNumberContainer, layer=IPyAMSLayer) @ajax_config(name='add-keynumber.json', context=IKeyNumberContainer, layer=IPyAMSLayer, base=AJAXAddForm) class KeyNumberAddForm(AdminDialogAddForm): @@ -231,7 +230,7 @@ icon_css_class = 'fa fa-fw fa-dashboard' fields = field.Fields(IKeyNumber).omit('__parent__', '__name__', 'visible') - edit_permission = MANAGE_CONTENT_PERMISSION + edit_permission = None # use context permission checker def create(self, data): return KeyNumber() @@ -249,7 +248,7 @@ } -@pagelet_config(name='properties.html', context=IKeyNumber, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) +@pagelet_config(name='properties.html', context=IKeyNumber, layer=IPyAMSLayer) @ajax_config(name='properties.json', context=IKeyNumber, layer=IPyAMSLayer) class KeyNumberPropertiesEditForm(AdminDialogEditForm): """Key number properties edit form""" @@ -260,7 +259,7 @@ icon_css_class = 'fa fa-fw fa-dashboard' fields = field.Fields(IKeyNumber).omit('__parent__', '__name__', 'visible') - edit_permission = MANAGE_CONTENT_PERMISSION + edit_permission = None # use context permission checker def get_ajax_output(self, changes): output = super(self.__class__, self).get_ajax_output(changes) diff -r b4e70a25236a -r d6548428279d src/pyams_content/shared/site/zmi/container.py