1 .. -*- coding: utf-8 -*- |
1 .. -*- coding: utf-8 -*- |
2 |
2 |
3 Workflow definition |
3 Workflow definition |
4 ====================== |
4 ====================== |
5 |
5 |
6 On peut mettre une condition rql ou/et un groupe auquel doit appartenir l'utilisateur. |
|
7 |
|
8 Si on met à la fois un(ou plusieurs) groupe et une condition RQL, il faut que les deux soient respectés. |
|
9 |
|
10 Si on met plusieurs groupes, il faut que l'utilisateur soit dans un des groupes. |
|
11 |
|
12 Pour la condition RQL sur une transition, on peut y mettre les substitutions suivantes : |
|
13 |
|
14 * `%(eid)s`, eid de l'objet |
|
15 * `%(ueid)s`, eid de l'utilisateur qui fait la requête |
|
16 * `%(seid)s`, eid de l'état courant de l'objet |
|
17 |
|
18 Dans le script de création d'un workflow, penser à mettre `_()` autour des noms d'états et de transitions |
|
19 pour que ceux si soient pris en compte par les scripts de gestion des catalogues i18n. |
|
20 |
|
21 General |
6 General |
22 ------- |
7 ------- |
23 |
8 |
24 A workflow can be defined in a `LAX` application thanks to the system |
9 A workflow can be defined in a `CubicWeb` application thanks to the system |
25 entities ``State`` and ``Transition``. Those are defined within all |
10 entities ``State`` and ``Transition``. Those are defined within all |
26 LAX application and can be set-up through the main administrator interface. |
11 `CubicWeb` application and can be set-up through the main administrator interface. |
27 |
12 |
28 Once your schema is defined, you can start creating the set of states and |
13 Once your schema is defined, you can start creating the set of states and |
29 the required transitions for your applications entities. |
14 the required transitions for your applications entities. |
30 |
15 |
31 You first need to define the states and then the transitions between those |
16 You first need to define the states and then the transitions between those |
125 |
110 |
126 add_transition(_('approve_blogentry'), 'BlogEntry', (submitted,), published, ('moderators', 'managers'),) |
111 add_transition(_('approve_blogentry'), 'BlogEntry', (submitted,), published, ('moderators', 'managers'),) |
127 |
112 |
128 checkpoint() |
113 checkpoint() |
129 |
114 |
|
115 .. note:: |
|
116 Do not forget to add the `_()` in front of all states and transitions names while creating |
|
117 a workflow so that they will be identified by the i18n catalog scripts. |
|
118 |
130 ``add_entity`` is used here to define the new group of users that we |
119 ``add_entity`` is used here to define the new group of users that we |
131 need to define the transitions, `moderators`. |
120 need to define the transitions, `moderators`. |
132 If this group required by the transition is not defined before the |
121 If this group required by the transition is not defined before the |
133 transition is created, it will not create the relation `transition |
122 transition is created, it will not create the relation `transition |
134 require the group moderator`. |
123 require the group moderator`. |
140 |
129 |
141 ``add_transition`` expects as the first argument the name of the |
130 ``add_transition`` expects as the first argument the name of the |
142 transition, then the entity type on which we can apply the transition, |
131 transition, then the entity type on which we can apply the transition, |
143 then the list of possible initial states from which the transition |
132 then the list of possible initial states from which the transition |
144 can be applied, the target state of the transition, and the permissions |
133 can be applied, the target state of the transition, and the permissions |
145 (e.g. list of the groups of users who can apply the transition). |
134 (e.g. list of the groups of users who can apply the transition, the user |
|
135 needs to belong to at least one of the listed group). |
|
136 |
|
137 |
|
138 We could have also added a RQL condition in addition to a group to |
|
139 which the user should belong to. |
|
140 |
|
141 If we use both RQL condition and group, the two must be satisfied |
|
142 for the user to be allowed to apply the transition. |
|
143 |
|
144 If we use a RQL condition on a transition, we can use the following |
|
145 variables: |
|
146 |
|
147 * `%(eid)s`, object's eid |
|
148 * `%(ueid)s`, user executing the query eid |
|
149 * `%(seid)s`, the object's current state eid |
|
150 |
146 |
151 |
147 .. image:: images/lax-book.03-transitions-view.en.png |
152 .. image:: images/lax-book.03-transitions-view.en.png |
148 |
153 |
149 You can now notice that in the actions box of a BlogEntry, the state |
154 You can now notice that in the actions box of a BlogEntry, the state |
150 is now listed as well as the possible transitions from this state |
155 is now listed as well as the possible transitions from this state |
151 defined by the workflow. This transition, as defined in the workflow, |
156 defined by the workflow. This transition, as defined in the workflow, |
152 will only being displayed for the users belonging to the group |
157 will only being displayed for the users belonging to the group |
153 moderators of managers. |
158 moderators of managers. |
154 |
159 |
155 |
|