<?xml version="1.0"?>
<dc-workflow workflow_id="survey"
             title="Survey workflow"
             description="Simple workflow for surveys to manage delete permissions"
             state_variable="review_state" initial_state="draft">
 <permission>Copy or Move</permission>
 <permission>Delete objects</permission>

 <state state_id="draft" title="Draft">
   <description>
     Unpublished surveys.
   </description>
  <exit-transition transition_id="publish"/>
  <permission-map name="Copy or Move" acquired="True">
    <permission-role>Authenticated</permission-role>
    <permission-role>Sector</permission-role>
    <permission-role>CountryManager</permission-role>
    <permission-role>Manager</permission-role>
  </permission-map>
  <permission-map name="Delete objects" acquired="False">
    <permission-role>Sector</permission-role>
    <permission-role>CountryManager</permission-role>
    <permission-role>Manager</permission-role>
  </permission-map>
 </state>

 <state state_id="published" title="Published">
   <description>
     Published surveys.
   </description>
  <exit-transition transition_id="update"/>
  <exit-transition transition_id="retract"/>
  <permission-map name="Copy or Move" acquired="True">
    <permission-role>Authenticated</permission-role>
    <permission-role>Sector</permission-role>
    <permission-role>CountryManager</permission-role>
    <permission-role>Manager</permission-role>
  </permission-map>
  <permission-map name="Delete objects" acquired="False">
    <permission-role>Sector</permission-role>
    <permission-role>CountryManager</permission-role>
    <permission-role>Manager</permission-role>
  </permission-map>
 </state>

 <transition transition_id="publish" new_state="published"
             title="Reviewer publishes content"
             trigger="USER"
             before_script="" after_script="">
  <description>
    Publishing the item makes it visible to other users.
  </description>
  <action url="%(content_url)s/content_status_modify?workflow_action=publish"
          category="workflow">Publish</action>
  <guard>
   <guard-permission>Euphorie: Publish a survey</guard-permission>
  </guard>
 </transition>

 <transition transition_id="update" new_state="published"
             title="Reviewer publishes content"
             trigger="USER"
             before_script="" after_script="">
  <description>
    Publish any updates made in the sector.
  </description>
  <action url="%(content_url)s/content_status_modify?workflow_action=update"
          category="workflow">Update</action>
  <guard>
   <guard-permission>Euphorie: Publish a survey</guard-permission>
  </guard>
 </transition>

 <transition transition_id="retract" new_state="draft"
             title="Retract survey"
             trigger="USER"
             before_script="" after_script="">
  <description>
    Retracting a survey removes it from the client.
  </description>
  <action url="%(content_url)s/content_status_modify?workflow_action=retract"
          category="workflow">Retract</action>
  <guard>
   <guard-permission>Euphorie: Publish a survey</guard-permission>
  </guard>
 </transition>

 <variable variable_id="action" for_catalog="False"
           for_status="True" update_always="True">
  <description>Previous 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>Comment 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>When the previous transition was performed
</description>
  <default>
   
   <expression>state_change/getDateTime</expression>
  </default>
  <guard>
  </guard>
 </variable>
</dc-workflow>
