Change State Viewlet

Does anyone have a 'Change State'-viewlet or button (I have some users that only will change state on content, so I dont want to show the 'Plone menu'.

You can change state in folder_contents too.

True, but I am making 'task management' as part of a site for a 'soccer club', so I am having one group that have only permissions on content type 'order', to change state of that (to 'delivered', 'wrong', 'somethingelse'.

So 'just one button would be nice'. I would prefer to do it without diazo.

Changing state means just print this link:

https://<mysite>/myobject/content_status_modify?workflow_action=publish&_authenticator=<the string>

print all the buttons to change state to the desired states and use tal:condition on workflow state to show only what is possible. A generic mechanism to get all the possible states should be available in the personal toolbar viewlet, which is included in the menu now. So just call the viewlet as broserview (there's a guide to do it) and get the data you need there. Something like:

    def get_viewlet_by_name(self, manager, name):
        manager = queryMultiAdapter((self.context, self.request, BrowserView(self.context, self.request)),
                                IViewletManager, manager, default=None)
        for viewlet in manager.viewlets:
            if viewlet.__name__ == name:
                return viewlet

    def get_actions(self): # here I get the actions but you can call any method of a viewlet
        viewlet = self.get_viewlet_by_name('plone.portaltop')
        if viewlet:
            return viewlet.get_actions()

Or just include the personal tool viewlet and delete what you don't need.

Actually, that would be quite simple/fast, since I could add a group portlet and add it there (especially, since I already have e 'above-contents-portlets'.

Since it is (now) possible to disable the toolbar (by settings), it can be done with a viewlet and a little bit of CSS and/or javascript. (those groups will not have permissions to edit portlets, add content or change display anyway:

I did a quick test, and this works


  <tal:contentviews tal:define="ploneview context/@@plone;"

  <div class="my-contentmenu">
      <div tal:replace="structure provider:plone.contentmenu" />

1 Like