From 6f240ac0b4bc7532e204a81949128fecd0ec57a4 Mon Sep 17 00:00:00 2001 From: EEA Jenkins <2368628+eea-jenkins@users.noreply.github.com> Date: Wed, 30 Aug 2023 23:12:06 +0300 Subject: [PATCH 1/4] Back to devel --- docs/HISTORY.txt | 3 +++ eea/volto/policy/version.txt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index aa8ccff..e6eb553 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,6 +1,9 @@ Changelog ========= +3.1-dev0 - (unreleased) +--------------------------- + 3.0 - (2023-08-30) --------------------------- * Feature: Add image_scales to catalog and update list of scales to registry diff --git a/eea/volto/policy/version.txt b/eea/volto/policy/version.txt index 9f55b2c..a8457d4 100644 --- a/eea/volto/policy/version.txt +++ b/eea/volto/policy/version.txt @@ -1 +1 @@ -3.0 +3.1-dev0 From 9b06c8316a0993d51b54d4f1f08965c0d8e2469a Mon Sep 17 00:00:00 2001 From: dobri1408 <50819975+dobri1408@users.noreply.github.com> Date: Thu, 31 Aug 2023 13:57:20 +0300 Subject: [PATCH 2/4] feat: Add content rule to unset publication date when private refs #147278 --- eea/volto/policy/configure.zcml | 1 + eea/volto/policy/contentrules/__init__.py | 2 + eea/volto/policy/contentrules/actions.py | 66 +++++++++++++++++++ eea/volto/policy/contentrules/configure.zcml | 29 ++++++++ .../policy/profiles/default/contentrules.xml | 18 +++++ .../policy/profiles/default/metadata.xml | 2 +- eea/volto/policy/upgrades/configure.zcml | 12 +++- 7 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 eea/volto/policy/contentrules/__init__.py create mode 100644 eea/volto/policy/contentrules/actions.py create mode 100644 eea/volto/policy/contentrules/configure.zcml create mode 100644 eea/volto/policy/profiles/default/contentrules.xml diff --git a/eea/volto/policy/configure.zcml b/eea/volto/policy/configure.zcml index 126f8b6..8311e1c 100644 --- a/eea/volto/policy/configure.zcml +++ b/eea/volto/policy/configure.zcml @@ -11,6 +11,7 @@ + diff --git a/eea/volto/policy/contentrules/__init__.py b/eea/volto/policy/contentrules/__init__.py new file mode 100644 index 0000000..837c684 --- /dev/null +++ b/eea/volto/policy/contentrules/__init__.py @@ -0,0 +1,2 @@ +""" Content rules +""" diff --git a/eea/volto/policy/contentrules/actions.py b/eea/volto/policy/contentrules/actions.py new file mode 100644 index 0000000..5d26341 --- /dev/null +++ b/eea/volto/policy/contentrules/actions.py @@ -0,0 +1,66 @@ +""" EEAContentTypes actions for plone.app.contentrules +""" + +import logging +from AccessControl import SpecialUsers, getSecurityManager +from AccessControl.SecurityManagement import ( + newSecurityManager, + setSecurityManager, +) +from OFS.SimpleItem import SimpleItem +from plone.app.contentrules.browser.formhelper import ( + NullAddForm, +) +from plone.contentrules.rule.interfaces import IExecutable, IRuleElementData +from zope.component import adapter +from zope.interface import Interface, implementer + +logger = logging.getLogger("eea.volto.policy") + + +class ISetPublicationDateToNullAction(Interface): + """Set Publication Date to null""" + + +@implementer(ISetPublicationDateToNullAction, IRuleElementData) +class SetPublicationDateToNullAction(SimpleItem): + """Set publication date to null action""" + + element = "eea.volto.policy.set_publication_date_to_null" + summary = ( + "I will set publication date to null" + ) + + +@implementer(IExecutable) +@adapter(Interface, ISetPublicationDateToNullAction, Interface) +class SetPublicationDateToNullExecutor(object): + """Set Publication Date to null executor""" + + def __init__(self, context, element, event): + self.context = context + self.element = element + self.event = event + + def __call__(self): + obj = self.event.object + try: + # Bypass user roles in order to rename old version + oldSecurityManager = getSecurityManager() + newSecurityManager(None, SpecialUsers.system) + obj.setEffectiveDate(None) + + # Switch back to the current user + setSecurityManager(oldSecurityManager) + except Exception as err: + logger.exception(err) + return True + return True + + +class SetPublicationDateToNullAddForm(NullAddForm): + """Set Publication Date to null addform""" + + def create(self): + """Create content-rule""" + return SetPublicationDateToNullAction() diff --git a/eea/volto/policy/contentrules/configure.zcml b/eea/volto/policy/contentrules/configure.zcml new file mode 100644 index 0000000..918e18c --- /dev/null +++ b/eea/volto/policy/contentrules/configure.zcml @@ -0,0 +1,29 @@ + + + + + + + + + + + + diff --git a/eea/volto/policy/profiles/default/contentrules.xml b/eea/volto/policy/profiles/default/contentrules.xml new file mode 100644 index 0000000..90af600 --- /dev/null +++ b/eea/volto/policy/profiles/default/contentrules.xml @@ -0,0 +1,18 @@ + + + + + + + private + + + + + + + + + diff --git a/eea/volto/policy/profiles/default/metadata.xml b/eea/volto/policy/profiles/default/metadata.xml index e4ba0c6..f1d491e 100644 --- a/eea/volto/policy/profiles/default/metadata.xml +++ b/eea/volto/policy/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 3.0 + 3.1 profile-plone.volto:default diff --git a/eea/volto/policy/upgrades/configure.zcml b/eea/volto/policy/upgrades/configure.zcml index f8a59ea..faa8138 100644 --- a/eea/volto/policy/upgrades/configure.zcml +++ b/eea/volto/policy/upgrades/configure.zcml @@ -36,7 +36,17 @@ title="Add image_scales to catalog and update list of scales to registry" import_steps="catalog plone.app.registry" /> - + + + + + From c1fcc45e63f7fa6057aba1c1b840eaba34d2397b Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Thu, 31 Aug 2023 14:01:59 +0300 Subject: [PATCH 3/4] Updated version to 3.1 --- eea/volto/policy/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eea/volto/policy/version.txt b/eea/volto/policy/version.txt index a8457d4..8c50098 100644 --- a/eea/volto/policy/version.txt +++ b/eea/volto/policy/version.txt @@ -1 +1 @@ -3.1-dev0 +3.1 From f670e967ac0e789b8ac6875d865c400c9698d927 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Thu, 31 Aug 2023 14:02:03 +0300 Subject: [PATCH 4/4] Updated changelog - removed develop information --- docs/HISTORY.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index e6eb553..220d60a 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,8 +1,10 @@ Changelog ========= -3.1-dev0 - (unreleased) +3.1 - (2023-08-31) --------------------------- +* Change: Feature: Add content rule to unset publication date when private [dobri1408 - refs #147278] + [avoinea] 3.0 - (2023-08-30) ---------------------------