doc/book/en/B0020-define-workflows.en.txt
changeset 306 1ed1da008e50
parent 287 adbf9a24c41e
child 858 e6ae125d5903
equal deleted inserted replaced
305:a4ee7cd025a7 306:1ed1da008e50
    45 it reaches the state published]
    45 it reaches the state published]
    46 
    46 
    47 Set-up a workflow
    47 Set-up a workflow
    48 -----------------
    48 -----------------
    49 
    49 
    50 Before starting, make sure you refresh your mind by reading [link to
       
    51 definition_workflow chapter].
       
    52 
       
    53 We want to create a workflow to control the quality of the BlogEntry 
    50 We want to create a workflow to control the quality of the BlogEntry 
    54 submitted on your application. When a BlogEntry is created by a user
    51 submitted on your application. When a BlogEntry is created by a user
    55 its state should be `submitted`. To be visible to all, it needs to
    52 its state should be `submitted`. To be visible to all, it needs to
    56 be in the state `published`. To move from `submitted` to `published`
    53 be in the state `published`. To move from `submitted` to `published`
    57 we need a transition that we can name `approve_blogentry`.
    54 we need a transition that we can name `approve_blogentry`.
    60 BlogEntry. We need to define a group of user, `moderators`, and 
    57 BlogEntry. We need to define a group of user, `moderators`, and 
    61 this group will have appropriate permissions to approve BlogEntry
    58 this group will have appropriate permissions to approve BlogEntry
    62 to be published and visible to all.
    59 to be published and visible to all.
    63 
    60 
    64 There are two ways to create a workflow, form the user interface,
    61 There are two ways to create a workflow, form the user interface,
    65 and also by defining it in ``migration/postcreate.py``. This script
    62 and also by defining it in ``migration/postcreate.py``. 
    66 is executed each time a new ``./bin/laxctl db-init`` is done. 
    63 This script is executed each time a new ``cubicweb-ctl db-init`` is done. 
    67 If you create the states and transitions through the user interface
    64 If you create the states and transitions through the user interface
    68 this means that next time you will need to initialize the database
    65 this means that next time you will need to initialize the database
    69 you will have to re-create all the entities. 
    66 you will have to re-create all the entities. 
    70 We strongly recommand you create the workflow in ``migration\postcreate.py``
    67 We strongly recommand you create the workflow in ``migration\postcreate.py``
    71 and we will now show you how.
    68 and we will now show you how.
    87       text = String(fulltextindexed=True)
    84       text = String(fulltextindexed=True)
    88       category = String(vocabulary=('important','business'))
    85       category = String(vocabulary=('important','business'))
    89       entry_of = SubjectRelation('Blog', cardinality='?*')
    86       entry_of = SubjectRelation('Blog', cardinality='?*')
    90       in_state = SubjectRelation('State', cardinality='1*')
    87       in_state = SubjectRelation('State', cardinality='1*')
    91 
    88 
    92 As you updated the schema, you will have re-execute ``./bin/laxctl db-init``
    89 As you updated the schema, you will have re-execute ``cubicweb-ctl db-init``
    93 to initialize the database and migrate your existing entities.
    90 to initialize the database and migrate your existing entities.
    94 [WRITE ABOUT MIGRATION]
    91 [WRITE ABOUT MIGRATION]
    95 
    92 
    96 Create states, transitions and group permissions
    93 Create states, transitions and group permissions
    97 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    94 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~