From 8907d1008e86be2e23f20dc3d9fd81bc5d2448e0 Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Thu, 26 Sep 2024 14:47:02 +0200 Subject: [PATCH] Adapted `meeting_workflow` so `Editor` may change a meeting `review_state` and not only the `Owner`. `Owner` is not more managed by `meeting_workflow`. Fix meeting `review_state` could not be changed by another user than the `Owner`. --- CHANGES.rst | 5 ++- .../workflows/meeting_workflow/definition.xml | 36 +++++-------------- src/plonemeeting/portal/core/setuphandlers.py | 2 +- .../portal/core/tests/portal_test_case.py | 8 ++++- .../portal/core/tests/test_workflow.py | 23 ++++++++++++ 5 files changed, 44 insertions(+), 30 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1a063c97..608deaa1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,10 @@ Changelog - Fixed wrong link on `preview_meeting.pt`. [aduchene] - +- Adapted `meeting_workflow` so `Editor` may change a meeting `review_state` + and not only the `Owner`. `Owner` is not more managed by `meeting_workflow`. + Fix meeting `review_state` could not be changed by another user than the `Owner`. + [gbastien] 2.0.0 (2024-09-23) ------------------ diff --git a/src/plonemeeting/portal/core/profiles/default/workflows/meeting_workflow/definition.xml b/src/plonemeeting/portal/core/profiles/default/workflows/meeting_workflow/definition.xml index fc16d4a9..a4471d11 100644 --- a/src/plonemeeting/portal/core/profiles/default/workflows/meeting_workflow/definition.xml +++ b/src/plonemeeting/portal/core/profiles/default/workflows/meeting_workflow/definition.xml @@ -4,12 +4,13 @@ workflow_id="meeting_workflow" title="Meeting Workflow" state_variable="review_state" initial_state="private" manager_bypass="False" i18n:attributes="title"> + Access contents information Delete objects Modify portal content View - Request review Review portal content + @@ -19,30 +20,24 @@ Manager - Owner Editor Site Administrator Anonymous - - Manager - Owner - Site Administrator - Manager - Owner + Editor Site Administrator + Manager - Owner Editor Reader Contributor @@ -50,29 +45,23 @@ Manager - Owner Editor Site Administrator Manager - Owner Editor Reader Contributor Site Administrator - - Manager - Owner - Site Administrator - Manager - Owner + Editor Site Administrator + @@ -81,21 +70,15 @@ Manager - Owner Editor Site Administrator Anonymous - - Manager - Owner - Site Administrator - Manager - Owner + Editor Site Administrator @@ -110,7 +93,7 @@ Back to private - Request review + Review portal content @@ -124,7 +107,7 @@ Send to project - Request review + Review portal content @@ -165,7 +148,6 @@ state_change/getHistory - Request review Review portal content diff --git a/src/plonemeeting/portal/core/setuphandlers.py b/src/plonemeeting/portal/core/setuphandlers.py index eaa07996..7a3378a9 100644 --- a/src/plonemeeting/portal/core/setuphandlers.py +++ b/src/plonemeeting/portal/core/setuphandlers.py @@ -31,7 +31,6 @@ import json import mimetypes import os -import transaction @implementer(INonInstallable) @@ -230,6 +229,7 @@ def create_demo_content(context): portal.portal_workflow.updateRoleMappings() + def create_demo_publications(portal, context): current_dir = os.path.abspath(os.path.dirname(__file__)) diff --git a/src/plonemeeting/portal/core/tests/portal_test_case.py b/src/plonemeeting/portal/core/tests/portal_test_case.py index cfee9f32..759fd269 100644 --- a/src/plonemeeting/portal/core/tests/portal_test_case.py +++ b/src/plonemeeting/portal/core/tests/portal_test_case.py @@ -6,6 +6,7 @@ from plone.app.testing import TEST_USER_NAME from plonemeeting.portal.core.testing import PLONEMEETING_PORTAL_CORE_INTEGRATION_TESTING from plonemeeting.portal.core.testing import PLONEMEETING_PORTAL_DEMO_FUNCTIONAL_TESTING +from plonemeeting.portal.core.utils import get_decisions_managers_group_id import unittest @@ -72,7 +73,9 @@ class PmPortalDemoFunctionalTestCase(PmPortalTestCase): def setUp(self): super().setUp() self.institution = self.portal["amityville"] - + self.portal.acl_users._doAddUser("amityville-decisions-manager2", "secretmaster", [], []) + group = api.group.get(get_decisions_managers_group_id(self.institution)) + group.addMember("amityville-decisions-manager2") self.meeting = api.content.find(self.institution, portal_type="Meeting")[ 0 ].getObject() @@ -82,5 +85,8 @@ def setUp(self): def login_as_decisions_manager(self): login(self.portal, "amityville-decisions-manager") + def login_as_decisions_manager2(self): + login(self.portal, "amityville-decisions-manager2") + def login_as_publications_manager(self): login(self.portal, "amityville-publications-manager") diff --git a/src/plonemeeting/portal/core/tests/test_workflow.py b/src/plonemeeting/portal/core/tests/test_workflow.py index 159ea7d6..c7fa9d57 100644 --- a/src/plonemeeting/portal/core/tests/test_workflow.py +++ b/src/plonemeeting/portal/core/tests/test_workflow.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- + +from imio.helpers.workflow import get_transitions from plone import api from plone.app.testing import login from plone.app.testing import logout @@ -480,3 +482,24 @@ def testRemoveContent(self): self.assertFalse(checkPerm(DeleteObjects, self.meeting)) self.assertFalse(checkPerm(DeleteObjects, self.item)) self.assertFalse(checkPerm(DeleteObjects, self.publications)) + + def test_any_decisions_manager_may_change_review_state(self): + # private + self.login_as_decisions_manager() + self.assertEqual(get_transitions(self.meeting), ["send_to_project"]) + self.login_as_decisions_manager2() + self.assertEqual(get_transitions(self.meeting), ["send_to_project"]) + # in_project + self.workflow.doActionFor(self.meeting, "send_to_project") + self.login_as_decisions_manager() + self.assertEqual(sorted(get_transitions(self.meeting)), + ["back_to_private", "publish"]) + self.login_as_decisions_manager2() + self.assertEqual(sorted(get_transitions(self.meeting)), + ["back_to_private", "publish"]) + # decision + self.workflow.doActionFor(self.meeting, "publish") + self.login_as_decisions_manager() + self.assertEqual(get_transitions(self.meeting), ["back_to_project"]) + self.login_as_decisions_manager2() + self.assertEqual(get_transitions(self.meeting), ["back_to_project"])