From a7e2e6e6f452787d57dbb23018cbada6cff4b2ec Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Thu, 2 Jul 2026 08:54:41 +0200 Subject: [PATCH 1/3] upgrade step to set discussion moderation icon --- news/+icon.feature | 1 + src/plone/app/upgrade/v62/configure.zcml | 14 +++++++++ src/plone/app/upgrade/v62/final.py | 37 ++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 news/+icon.feature diff --git a/news/+icon.feature b/news/+icon.feature new file mode 100644 index 00000000..d79467bb --- /dev/null +++ b/news/+icon.feature @@ -0,0 +1 @@ +Upgrade step to set the discussion moderation icon to be bootstrap based icon @erral diff --git a/src/plone/app/upgrade/v62/configure.zcml b/src/plone/app/upgrade/v62/configure.zcml index 2412293b..a4ab67d0 100644 --- a/src/plone/app/upgrade/v62/configure.zcml +++ b/src/plone/app/upgrade/v62/configure.zcml @@ -87,4 +87,18 @@ /> + + + + + + + diff --git a/src/plone/app/upgrade/v62/final.py b/src/plone/app/upgrade/v62/final.py index e69de29b..0b25582c 100644 --- a/src/plone/app/upgrade/v62/final.py +++ b/src/plone/app/upgrade/v62/final.py @@ -0,0 +1,37 @@ +from plone.base.utils import get_installer +from Products.CMFCore.utils import getToolByName + +import logging + +logger = logging.getLogger(__name__) + + +def manage_comments_icon(context): + """if plone.app.discussion is installed, set the manage-comments action icon + expression from its default to the bootstrap based new-style icons + """ + + installer = get_installer(context) + if installer.is_product_installed("plone.app.discussion"): + portal_actions = getToolByName(context, "portal_actions") + user_actions = getattr(portal_actions, "user", None) + if user_actions is not None: + review_comments_action = getattr(user_actions, "review-comments", None) + if review_comments_action is not None: + # Check whether the action keeps its original state + if ( + review_comments_action.icon_expr + == "string:${globals_view/navigationRootUrl}/discussionitem_icon.png" + ): + review_comments_action.icon_expr = "string:chat" + logger.info("Action icon modified for manage comments action") + else: + logger.info( + "Manage comments action icon expression was modified by the user" + ) + else: + logger.info("There is no manage comments action") + else: + logger.info("There are no user actions") + else: + logger.info("plone.app.discussion is not installed. Nothing is done.") From 027b4046d61a39828cbce7cf5633a36bc19cbaf1 Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Thu, 2 Jul 2026 09:22:44 +0200 Subject: [PATCH 2/3] improve wording of the logs --- src/plone/app/upgrade/v62/final.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plone/app/upgrade/v62/final.py b/src/plone/app/upgrade/v62/final.py index 0b25582c..cbc81919 100644 --- a/src/plone/app/upgrade/v62/final.py +++ b/src/plone/app/upgrade/v62/final.py @@ -24,14 +24,14 @@ def manage_comments_icon(context): == "string:${globals_view/navigationRootUrl}/discussionitem_icon.png" ): review_comments_action.icon_expr = "string:chat" - logger.info("Action icon modified for manage comments action") + logger.info("Manage comments action icon modified") else: logger.info( - "Manage comments action icon expression was modified by the user" + "Manage comments action icon was modified by the user. Nothing is done." ) else: - logger.info("There is no manage comments action") + logger.info("There is no manage comments action. Nothing is done.") else: - logger.info("There are no user actions") + logger.info("There are no user actions. Nothing si done.") else: logger.info("plone.app.discussion is not installed. Nothing is done.") From ad49a9936afd109bc151d9506f8db0cbaa000a14 Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Thu, 2 Jul 2026 15:58:01 +0200 Subject: [PATCH 3/3] flatten the ifs --- src/plone/app/upgrade/v62/final.py | 48 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/plone/app/upgrade/v62/final.py b/src/plone/app/upgrade/v62/final.py index cbc81919..803226c2 100644 --- a/src/plone/app/upgrade/v62/final.py +++ b/src/plone/app/upgrade/v62/final.py @@ -12,26 +12,30 @@ def manage_comments_icon(context): """ installer = get_installer(context) - if installer.is_product_installed("plone.app.discussion"): - portal_actions = getToolByName(context, "portal_actions") - user_actions = getattr(portal_actions, "user", None) - if user_actions is not None: - review_comments_action = getattr(user_actions, "review-comments", None) - if review_comments_action is not None: - # Check whether the action keeps its original state - if ( - review_comments_action.icon_expr - == "string:${globals_view/navigationRootUrl}/discussionitem_icon.png" - ): - review_comments_action.icon_expr = "string:chat" - logger.info("Manage comments action icon modified") - else: - logger.info( - "Manage comments action icon was modified by the user. Nothing is done." - ) - else: - logger.info("There is no manage comments action. Nothing is done.") - else: - logger.info("There are no user actions. Nothing si done.") - else: + if not installer.is_product_installed("plone.app.discussion"): logger.info("plone.app.discussion is not installed. Nothing is done.") + return + + portal_actions = getToolByName(context, "portal_actions") + user_actions = getattr(portal_actions, "user", None) + if user_actions is None: + logger.info("There are no user actions. Nothing is done.") + return + + review_comments_action = getattr(user_actions, "review-comments", None) + if review_comments_action is None: + logger.info("There is no manage comments action. Nothing is done.") + return + + # Check whether the action keeps its original state + if ( + review_comments_action.icon_expr + != "string:${globals_view/navigationRootUrl}/discussionitem_icon.png" + ): + logger.info( + "Manage comments action icon was modified by the user. Nothing is done." + ) + return + + review_comments_action.icon_expr = "string:chat" + logger.info("Manage comments action icon modified")