Products.CMFPlone/support-remove-controlpanel-43: Supported 'remove' keyword for configlets in controlpanel.xm

Maurits van Rees <jenkins-z4DKO/[email protected]> Wed, 02 Aug 2017 09:10:02 -0700 (PDT)
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: Products.CMFPlone
Branch: refs/heads/support-remove-controlpanel-43
Date: 2017-08-02T18:05:50+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/Products.CMFPlone/commit/eb6aca35962e10bc50bcd2a7162a5a087a4ae1b4

Supported 'remove' keyword for configlets in controlpanel.xml.

Backported from master, see https://github.com/plone/Products.CMFPlone/pull/1372

Files changed:
M Products/CMFPlone/exportimport/controlpanel.py
M docs/CHANGES.rst

diff --git a/Products/CMFPlone/exportimport/controlpanel.py b/Products/CMFPlone/exportimport/controlpanel.py
index 4db290c16..acb4c52ad 100644
--- a/Products/CMFPlone/exportimport/controlpanel.py
+++ b/Products/CMFPlone/exportimport/controlpanel.py
@@ -113,6 +113,12 @@ def _initConfiglets(self, node):
                 domain = default_domain
 
             action_id = str(child.getAttribute('action_id'))
+            # Remove previous action with same id and category.
+            controlpanel.unregisterConfiglet(action_id)
+            remove = str(child.getAttribute('remove'))
+            if remove.lower() == 'true':
+                continue
+
             title = Message(str(child.getAttribute('title')), domain=domain)
             url_expr = str(child.getAttribute('url_expr'))
             condition_expr = str(child.getAttribute('condition_expr'))
@@ -137,9 +143,6 @@ def _initConfiglets(self, node):
                     if permission:
                         break
 
-            # Remove previous action with same id and category.
-            controlpanel.unregisterConfiglet(action_id)
-
             controlpanel.registerConfiglet(id=action_id,
                                            name=title,
                                            action=url_expr,
diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst
index 3006c4330..d20d9dab9 100644
--- a/docs/CHANGES.rst
+++ b/docs/CHANGES.rst
@@ -11,6 +11,9 @@ Changelog
 
 Bug fixes:
 
+- Support 'remove' keyword for configlets in controlpanel.xml.
+  [maurits]
+
 - Add data-base-url attribute in body tag.
   Closes `issue 2051 <https://github.com/plone/Products.CMFPlone/issues/2051>`_
   [rodfersou]



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot