Skip to content

Commit

Permalink
Adapted meeting_workflow so Editor may change a meeting `review_s…
Browse files Browse the repository at this point in the history
…tate` 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`.
  • Loading branch information
gbastien committed Sep 26, 2024
1 parent 28e6985 commit 8907d10
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 30 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
workflow_id="meeting_workflow" title="Meeting Workflow"
state_variable="review_state" initial_state="private" manager_bypass="False"
i18n:attributes="title">

<permission>Access contents information</permission>
<permission>Delete objects</permission>
<permission>Modify portal content</permission>
<permission>View</permission>
<permission>Request review</permission>
<permission>Review portal content</permission>

<state state_id="in_project" title="In project" i18n:attributes="title">
<description></description>
<exit-transition transition_id="publish"/>
Expand All @@ -19,60 +20,48 @@
</permission-map>
<permission-map name="Modify portal content" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Editor</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
<permission-map name="View" acquired="False">
<permission-role>Anonymous</permission-role>
</permission-map>
<permission-map name="Request review" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
<permission-map name="Review portal content" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Editor</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
</state>

<state state_id="private" title="Private" i18n:attributes="title">
<description></description>
<exit-transition transition_id="send_to_project"/>
<permission-map name="Access contents information" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Editor</permission-role>
<permission-role>Reader</permission-role>
<permission-role>Contributor</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
<permission-map name="Modify portal content" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Editor</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
<permission-map name="View" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Editor</permission-role>
<permission-role>Reader</permission-role>
<permission-role>Contributor</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
<permission-map name="Request review" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
<permission-map name="Review portal content" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Editor</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
</state>

<state state_id="decision" title="Decision" i18n:attributes="title">
<description></description>
<exit-transition transition_id="back_to_project"/>
Expand All @@ -81,21 +70,15 @@
</permission-map>
<permission-map name="Modify portal content" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Editor</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
<permission-map name="View" acquired="False">
<permission-role>Anonymous</permission-role>
</permission-map>
<permission-map name="Request review" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
<permission-map name="Review portal content" acquired="False">
<permission-role>Manager</permission-role>
<permission-role>Owner</permission-role>
<permission-role>Editor</permission-role>
<permission-role>Site Administrator</permission-role>
</permission-map>
</state>
Expand All @@ -110,7 +93,7 @@
<description></description>
<action url="%(content_url)s/content_status_modify?workflow_action=back_to_private" category="workflow" icon="">Back to private</action>
<guard>
<guard-permission>Request review</guard-permission>
<guard-permission>Review portal content</guard-permission>
</guard>
</transition>
<transition transition_id="back_to_project" title="Back to project" new_state="in_project" trigger="USER" before_script="" after_script="" i18n:attributes="title">
Expand All @@ -124,7 +107,7 @@
<description></description>
<action url="%(content_url)s/content_status_modify?workflow_action=send_to_project" category="workflow" icon="">Send to project</action>
<guard>
<guard-permission>Request review</guard-permission>
<guard-permission>Review portal content</guard-permission>
</guard>
</transition>
<worklist worklist_id="reviewer_queue" title="">
Expand Down Expand Up @@ -165,7 +148,6 @@
<expression>state_change/getHistory</expression>
</default>
<guard>
<guard-permission>Request review</guard-permission>
<guard-permission>Review portal content</guard-permission>
</guard>
</variable>
Expand Down
2 changes: 1 addition & 1 deletion src/plonemeeting/portal/core/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import json
import mimetypes
import os
import transaction


@implementer(INonInstallable)
Expand Down Expand Up @@ -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__))

Expand Down
8 changes: 7 additions & 1 deletion src/plonemeeting/portal/core/tests/portal_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand All @@ -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")
23 changes: 23 additions & 0 deletions src/plonemeeting/portal/core/tests/test_workflow.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"])

0 comments on commit 8907d10

Please sign in to comment.