author | sylvain.thenault@logilab.fr |
Wed, 11 Feb 2009 13:52:01 +0100 | |
changeset 573 | 9c8fd72ba6c1 |
parent 93 | 9c919a47e140 |
child 1398 | 5fe84a5f7035 |
permissions | -rw-r--r-- |
0 | 1 |
.. -*- coding: utf-8 -*- |
2 |
||
3 |
Définition de workflow |
|
4 |
====================== |
|
5 |
On peut mettre une condition rql ou/et un groupe auquel doit appartenir l'utilisateur. |
|
6 |
||
7 |
Si on met à la fois un(ou plusieurs) groupe et une condition RQL, il faut que les deux soient respectés. |
|
8 |
||
9 |
Si on met plusieurs groupes, il faut que l'utilisateur soit dans un des groupes. |
|
10 |
||
11 |
Pour la condition RQL sur une transition, on peut y mettre les substitutions suivantes : |
|
12 |
||
13 |
* `%(eid)s`, eid de l'objet |
|
14 |
* `%(ueid)s`, eid de l'utilisateur qui fait la requête |
|
15 |
* `%(seid)s`, eid de l'état courant de l'objet |
|
16 |
||
17 |
Dans le script de création d'un workflow, penser à mettre `_()` autour des noms d'états et de transitions |
|
18 |
pour que ceux si soient pris en compte par les scripts de gestion des catalogues i18n. |
|
71
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
19 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
20 |
General |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
21 |
------- |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
22 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
23 |
A workflow can be defined in a `LAX` application thanks to the system |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
24 |
entities ``State`` and ``Transition``. Those are defined within all |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
25 |
LAX application and can be set-up through the main administrator interface. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
26 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
27 |
Once your schema is defined, you can start creating the set of states and |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
28 |
the required transitions for your applications entities. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
29 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
30 |
You first need to define the states and then the transitions between those |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
31 |
to complete your workflow. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
32 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
33 |
A ``State`` defines the status of an entity. While creating a new state, |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
34 |
you will be first given the option to select the entity type the state |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
35 |
can be applied to. By choosing ``Apply``, a new section will be displayed |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
36 |
in the editing screen to enable you to add relation to the state you are |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
37 |
creating. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
38 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
39 |
A ``Transition`` is also based on an entity type it can be applied to. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
40 |
By choosing ``Apply``, a new section will be displayed in the editing |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
41 |
screen to enable you to add relation to the transition you are |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
42 |
creating. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
43 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
44 |
At the transition level you will also define the group of user which can |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
45 |
aplly this transition to an object. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
46 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
47 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
48 |
Example of a simple workflow |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
49 |
---------------------------- |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
50 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
51 |
Please see the tutorial to view and example of a simple workflow. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
52 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
53 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
54 |
[Create a simple workflow for BlogDemo, to have a moderator approve new blog |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
55 |
entry to be published. This implies, specify a dedicated group of blog |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
56 |
moderator as well as hide the view of a blog entry to the user until |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
57 |
it reaches the state published] |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
58 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
59 |
Set-up a workflow |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
60 |
----------------- |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
61 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
62 |
Before starting, make sure you refresh your mind by reading [link to |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
63 |
definition_workflow chapter]. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
64 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
65 |
We want to create a workflow to control the quality of the BlogEntry |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
66 |
submitted on your application. When a BlogEntry is created by a user |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
67 |
its state should be `submitted`. To be visible to all, it needs to |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
68 |
be in the state `published`. To move from `submitted` to `published` |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
69 |
we need a transition that we can name `approve_blogentry`. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
70 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
71 |
We do not want every user to be allowed to change the state of a |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
72 |
BlogEntry. We need to define a group of user, `moderators`, and |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
73 |
this group will have appropriate permissions to approve BlogEntry |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
74 |
to be published and visible to all. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
75 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
76 |
There are two ways to create a workflow, form the user interface, |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
77 |
and also by defining it in ``migration/postcreate.py``. This script |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
78 |
is executed each time a new ``./bin/laxctl db-init`` is done. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
79 |
If you create the states and transitions through the user interface |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
80 |
this means that next time you will need to initialize the database |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
81 |
you will have to re-create all the entities. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
82 |
We strongly recommand you create the workflow in ``migration\postcreate.py`` |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
83 |
and we will now show you how. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
84 |
The user interface would only be a reference for you to view the states |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
85 |
and transitions but is not the appropriate interface to define your |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
86 |
application workflow. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
87 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
88 |
Update the schema |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
89 |
~~~~~~~~~~~~~~~~~ |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
90 |
To enable a BlogEntry to have a State, we have to define a relation |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
91 |
``in_state`` in the schema of BlogEntry. Please do as follows, add |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
92 |
the line ``in_state (...)``:: |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
93 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
94 |
class BlogEntry(EntityType): |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
95 |
title = String(maxsize=100, required=True) |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
96 |
publish_date = Date(default='TODAY') |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
97 |
text_format = String(meta=True, internationalizable=True, maxsize=50, |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
98 |
default='text/rest', constraints=[format_constraint]) |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
99 |
text = String(fulltextindexed=True) |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
100 |
category = String(vocabulary=('important','business')) |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
101 |
entry_of = SubjectRelation('Blog', cardinality='?*') |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
102 |
in_state = SubjectRelation('State', cardinality='1*') |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
103 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
104 |
As you updated the schema, you will have re-execute ``./bin/laxctl db-init`` |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
105 |
to initialize the database and migrate your existing entities. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
106 |
[WRITE ABOUT MIGRATION] |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
107 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
108 |
Create states, transitions and group permissions |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
109 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
110 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
111 |
At the time the ``postcreate.py`` script is executed, several methods |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
112 |
can be used. They are all defined in the ``class ServerMigrationHelper``. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
113 |
We will only discuss the method we use to create a wrokflow here. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
114 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
115 |
To define our workflow for BlogDemo, please add the following lines |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
116 |
to ``migration/postcreate.py``:: |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
117 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
118 |
_ = unicode |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
119 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
120 |
moderators = add_entity('EGroup', name=u"moderators") |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
121 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
122 |
submitted = add_state(_('submitted'), 'BlogEntry', initial=True) |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
123 |
published = add_state(_('published'), 'BlogEntry') |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
124 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
125 |
add_transition(_('approve_blogentry'), 'BlogEntry', (submitted,), published, ('moderators', 'managers'),) |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
126 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
127 |
checkpoint() |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
128 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
129 |
``add_entity`` is used here to define the new group of users that we |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
130 |
need to define the transitions, `moderators`. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
131 |
If this group required by the transition is not defined before the |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
132 |
transition is created, it will not create the relation `transition |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
133 |
require the group moderator`. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
134 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
135 |
``add_state`` expects as the first argument the name of the state you are |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
136 |
willing to create, then the entity type on which the state can be applied, |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
137 |
and an optionnal argument to set if the state is the initial state |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
138 |
of the entity type or not. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
139 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
140 |
``add_transition`` expects as the first argument the name of the |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
141 |
transition, then the entity type on which we can apply the transition, |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
142 |
then the list of possible initial states from which the transition |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
143 |
can be applied, the target state of the transition, and the permissions |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
144 |
(e.g. list of the groups of users who can apply the transition). |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
145 |
|
90
7fd4ffeb082b
[doc] images were renamed and table of content changed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
71
diff
changeset
|
146 |
.. image:: images/lax-book.03-transitions-view.fr.png |
71
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
147 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
148 |
You can now notice that in the actions box of a BlogEntry, the state |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
149 |
is now listed as well as the possible transitions from this state |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
150 |
defined by the workflow. This transition, as defined in the workflow, |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
151 |
will only being displayed for the users belonging to the group |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
152 |
moderators of managers. |
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
153 |
|
69a4bf8f5e49
Moved content from tutoriel to introduction and to wrokflow chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
50
diff
changeset
|
154 |