Permalink
Browse files

Added test for applying a different workflow to the working copy

  • Loading branch information...
1 parent b420403 commit d7945b1f689aafaae85188f4c9ecf6680539dc84 Anthony Gerrard committed Mar 13, 2012
@@ -4,5 +4,6 @@
<dependency>profile-plone.app.dexterity:default</dependency>
<dependency>profile-plone.app.relationfield:default</dependency>
<dependency>profile-plone.app.iterate:plone.app.iterate</dependency>
+ <dependency>profile-Products.CMFPlacefulWorkflow:base</dependency>
</dependencies>
</metadata>
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<object name="portal_placeful_workflow" meta_type="Placeful Workflow Tool">
+ <property name="title"></property>
+ <property name="max_chain_length" type="int">1</property>
+ <object name="working-copy" meta_type="WorkflowPolicy" />
+</object>
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<object name="working-copy" meta_type="WorkflowPolicy">
+ <property name="title">Working Copy</property>
+ <bindings>
+ <default>
+ <bound-workflow workflow_id="workingcopy_workflow" />
+ </default>
+ <type default_chain="true" type_id="stageable_type" />
+ </bindings>
+</object>
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<object name="portal_workflow" meta_type="Plone Workflow Tool">
+ <object name="workingcopy_workflow" meta_type="Workflow" />
+</object>
@@ -0,0 +1,170 @@
+<?xml version="1.0"?>
+<dc-workflow xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="plone" workflow_id="workingcopy_workflow"
+ title="test wc workflow" state_variable="review_state" initial_state="draft-copy" i18n:attributes="title">
+
+ <!-- These are the permissions being managed -->
+ <permission>Delete objects</permission>
+ <permission>iterate : Check in content</permission>
+ <permission>iterate : Check out content</permission>
+ <permission>View</permission>
+ <permission>Access contents information</permission>
+ <permission>Change portal events</permission>
+ <permission>Modify portal content</permission>
+ <permission>Copy or Move</permission>
+
+ <!-- The various workflow states, with their permission maps -->
+ <state state_id="draft-copy" title="Draft (copy)" i18n:attributes="title">
+ <description i18n:translate="">New version created but not ready for publication</description>
+ <exit-transition transition_id="submit-copy-for-publication" />
+ <permission-map name="Access contents information" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Contributor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="Change portal events" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Contributor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="Modify portal content" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Contributor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="View" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Contributor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="iterate : Check in content" acquired="False" />
+ <permission-map name="iterate : Check out content" acquired="False" />
+ <permission-map name="Copy or Move" acquired="False" />
+ <permission-map name="Delete objects" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Contributor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ </state>
+
+ <state state_id="pending-copy" title="Pending (copy)" i18n:attributes="title">
+ <description i18n:translate="">Copy submitted for publication - pending approval</description>
+ <exit-transition transition_id="withdraw-submitted-copy" />
+ <exit-transition transition_id="reject-submitted-copy" />
+ <permission-map name="Access contents information" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Contributor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="Change portal events" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="Modify portal content" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="View" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Contributor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="iterate : Check in content" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ <permission-map name="iterate : Check out content" acquired="False" />
+ <permission-map name="Copy or Move" acquired="False" />
+ <permission-map name="Delete objects" acquired="False">
+ <permission-role>Editor</permission-role>
+ <permission-role>Site Administrator</permission-role>
+ <permission-role>Contributor</permission-role>
+ <permission-role>Manager</permission-role>
+ </permission-map>
+ </state>
+
+ <!-- Transitions between states, including guard conditions -->
+ <transition transition_id="submit-copy-for-publication" new_state="pending-copy" title="Submit draft content for publication" trigger="USER"
+ before_script="" after_script="" i18n:attributes="title">
+ <description i18n:translate="">
+ Move the content to the pending state where it will be reviewed by an editor by publication.
+ </description>
+ <action url="%(content_url)s/content_status_modify?workflow_action=submit-copy-for-publication" category="workflow"
+ i18n:translate="">Submit</action>
+ <guard>
+ <guard-permission>Modify portal content</guard-permission>
+ </guard>
+ </transition>
+ <transition transition_id="reject-submitted-copy" new_state="draft-copy" title="Editor rejects submitted content"
+ trigger="USER" before_script="" after_script="" i18n:attributes="title">
+ <description i18n:translate="">
+ Revert to draft.
+ </description>
+ <guard>
+ <guard-permission>Review portal content</guard-permission>
+ </guard>
+ </transition>
+ <transition transition_id="withdraw-submitted-copy" new_state="draft-copy" title="Contributor withdraws submitted content"
+ trigger="USER" before_script="" after_script="" i18n:attributes="title">
+ <description i18n:translate="">
+ Revert to draft.
+ </description>
+ <guard>
+ <guard-role>Contributor</guard-role>
+ </guard>
+ </transition>
+
+ <!-- Workflow variables, managed as part of workflow history -->
+ <variable variable_id="action" for_catalog="False" for_status="True" update_always="True">
+ <description>The last transition</description>
+ <default>
+ <expression>transition/getId|nothing</expression>
+ </default>
+ <guard>
+ </guard>
+ </variable>
+ <variable variable_id="actor" for_catalog="False" for_status="True" update_always="True">
+ <description>The ID of the user who performed the last transition</description>
+ <default>
+ <expression>user/getId</expression>
+ </default>
+ <guard>
+ </guard>
+ </variable>
+ <variable variable_id="comments" for_catalog="False" for_status="True" update_always="True">
+ <description>Comments about the last transition</description>
+ <default>
+ <expression>python:state_change.kwargs.get('comment', '')</expression>
+ </default>
+ <guard>
+ </guard>
+ </variable>
+ <variable variable_id="review_history" for_catalog="False" for_status="False" update_always="False">
+ <description>Provides access to workflow history</description>
+ <default>
+ <expression>state_change/getHistory</expression>
+ </default>
+ <guard>
+ <guard-permission>Request review</guard-permission>
+ <guard-permission>Review portal content</guard-permission>
+ </guard>
+ </variable>
+ <variable variable_id="time" for_catalog="False" for_status="True" update_always="True">
+ <description>Time of the last transition</description>
+ <default>
+ <expression>state_change/getDateTime</expression>
+ </default>
+ <guard>
+ </guard>
+ </variable>
+
+</dc-workflow>
@@ -77,3 +77,38 @@ Cancel checkout
>>> browser.getControl(name='form.button.Cancel').click()
>>> browser.url
'http://nohost/plone/test_folder/stageable_type'
+
+Working copy workflows
+----------------------
+
+It's possible to assign a different workflow to working copies in combination with
+Products.CMFPlacefulWorkflow. This usually makes sense: you should be checking in a working copy
+rather than publishing it.
+
+We have a working copy workflow defined in our textfixture profile. To enable you need to set a
+couple of site properties.
+
+ >>> browser.open("http://nohost/plone/portal_properties/site_properties/manage_propertiesForm")
+ >>> browser.getControl(name="enable_checkout_workflow:boolean").value = [True]
+ >>> browser.getControl(name="checkout_workflow_policy:string").value = 'working-copy'
+ >>> browser.getControl(name="manage_editProperties:method").click()
+
+Create a new page to test workflows with
+
+ >>> browser.open("http://nohost/plone/test_folder/folder_factories")
+ >>> browser.contents
+ '...stageable_type...'
+ >>> browser.getControl("Stageable Type").click()
+ >>> browser.getControl("Add").click()
+ >>> browser.getControl(name="form.widgets.IDublinCore.title").value = "My workflow test"
+ >>> browser.getControl(name="form.buttons.save").click()
+ >>> browser.url
+ 'http://nohost/plone/test_folder/stageable_type-1/view'
+
+Checkout
+
+ >>> browser.getLink(id='iterate_checkout').click()
+ >>> browser.contents
+ '...This is a working copy of...My workflow test..., made by...admin... on...'
+ >>> browser.contents
+ '...state-draft-copy...'
@@ -2,15 +2,19 @@
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import IntegrationTesting, FunctionalTesting
+from plone.testing import z2
class Fixture(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE,)
def setUpZope(self, app, configurationContext):
import plone.app.stagingbehavior
import plone.app.versioningbehavior
+ import Products.CMFPlacefulWorkflow
self.loadZCML(package=plone.app.stagingbehavior)
self.loadZCML(package=plone.app.versioningbehavior)
+ self.loadZCML(package=Products.CMFPlacefulWorkflow)
+ z2.installProduct(app, 'Products.CMFPlacefulWorkflow')
def setUpPloneSite(self, portal):
self.applyProfile(portal, 'plone.app.stagingbehavior:testfixture')
View
@@ -36,7 +36,8 @@
'test': [
'plone.app.testing',
'plone.app.versioningbehavior',
- 'plone.app.referenceablebehavior'
+ 'plone.app.referenceablebehavior',
+ 'Products.CMFPlacefulWorkflow',
],
},
entry_points="""

0 comments on commit d7945b1

Please sign in to comment.