Reputation: 2568
We have a utility (collective.contentalerts) that checks if the content of an object (say an article) is adequate or not (does not contain bad words).
So far we have been using it together with plone.app.contentrules
to send emails when that happens.
Now we want to go one step further:
Regular users can still create their articles but whenever they are trying to make them public, if the utility finds fishy content on it, it should put them in another state (i.e. make another workflow transition instead).
So the question is: is there a way to intercept a workflow transition, and given some logic (our utility) change the intended workflow transition to another one?
Extra nice would be that this transition to the moderation state should not be seen by regular users on the workflow transition drop down.
Upvotes: 3
Views: 189
Reputation: 1238
I don't think it is necessary to intercept a transition: show users the transition "publish" which sends the object to the state "needs_review"
Use an automatic transition from state "needs_review" to "public" that is guarded with a view that checks if the article is ok (does not contain words from your blacklist, etc)
This way users see the "publish" transition (not "send to moderation").
An example on how to configure a guard expression can be found on the Poi add-on.
Think about something like this:
<guard-expression>here/@@myview</guard-expression>
Where myview
can be a public view that perform all of the needed check and return True/False.
The trigger type of the transition has to be automatic instead of "initiated by user" (see screenshot)
if you follow the [?] questionmark link next to the expression field you get more information on the available variables.
Upvotes: 7