Workflow#
Note
Currently the workflow support is limited to executing transitions on content.
In Plone, content almost always has a workflow attached.
We can get the current state and history of an object by issuing a GET
request for any context:
GET /plone/front-page/@workflow HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
curl -i -X GET http://nohost/plone/front-page/@workflow -H "Accept: application/json" --user admin:secret
http http://nohost/plone/front-page/@workflow Accept:application/json -a admin:secret
requests.get('http://nohost/plone/front-page/@workflow', headers={'Accept': 'application/json'}, auth=('admin', 'secret'))
HTTP/1.1 200 OK
Content-Type: application/json
{
"@id": "http://localhost:55001/plone/front-page/@workflow",
"history": [
{
"action": null,
"actor": "test_user_1_",
"comments": "",
"review_state": "private",
"time": "1995-07-31T17:30:00+00:00",
"title": "Private"
}
],
"state": {
"id": "private",
"title": "Private"
},
"transitions": [
{
"@id": "http://localhost:55001/plone/front-page/@workflow/publish",
"title": "Publish"
},
{
"@id": "http://localhost:55001/plone/front-page/@workflow/submit",
"title": "Submit for publication"
}
]
}
Now if we want to change the state of the front page to publish, we would proceed by issuing a POST
request to the given URL:
POST /plone/front-page/@workflow/publish HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
curl -i -X POST http://nohost/plone/front-page/@workflow/publish -H "Accept: application/json" --user admin:secret
http POST http://nohost/plone/front-page/@workflow/publish Accept:application/json -a admin:secret
requests.post('http://nohost/plone/front-page/@workflow/publish', headers={'Accept': 'application/json'}, auth=('admin', 'secret'))
HTTP/1.1 200 OK
Content-Type: application/json
{
"action": "publish",
"actor": "admin",
"comments": "",
"review_state": "published",
"time": "1995-07-31T18:30:00+00:00",
"title": "Published with accent \u00e9"
}
We can also change the state recursively for all contained items, provide a comment, and set effective and expiration dates:
POST /plone/folder/@workflow/publish HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
Content-Type: application/json
{
"comment": "Publishing my folder...",
"effective": "2018-01-21T08:00:00",
"expires": "2019-01-21T08:00:00",
"include_children": true
}
curl -i -X POST http://nohost/plone/folder/@workflow/publish -H "Accept: application/json" -H "Content-Type: application/json" --data-raw '{"comment": "Publishing my folder...", "effective": "2018-01-21T08:00:00", "expires": "2019-01-21T08:00:00", "include_children": true}' --user admin:secret
echo '{
"comment": "Publishing my folder...",
"effective": "2018-01-21T08:00:00",
"expires": "2019-01-21T08:00:00",
"include_children": true
}' | http POST http://nohost/plone/folder/@workflow/publish Accept:application/json Content-Type:application/json -a admin:secret
requests.post('http://nohost/plone/folder/@workflow/publish', headers={'Accept': 'application/json', 'Content-Type': 'application/json'}, json={'comment': 'Publishing my folder...', 'effective': '2018-01-21T08:00:00', 'expires': '2019-01-21T08:00:00', 'include_children': True}, auth=('admin', 'secret'))
HTTP/1.1 200 OK
Content-Type: application/json
{
"action": "publish",
"actor": "admin",
"comments": "Publishing my folder...",
"review_state": "published",
"time": "1995-07-31T18:30:00+00:00",
"title": "Published with accent \u00e9"
}