(Ongoing translation assisted by Google translate, be indulgent please)
GoFlow User Guide
GoFlow is a django component which adds workflow features to a django project.
We'll learn here how to use this module, starting with a very simple "Hello world" django project, and then gradually add features.
Prerequisite
Create a directory, and copy the directory goflow to this directory (you can also place it in any directory in your PYTHONPATH).
Note:
In what follows, the use of relative paths, while the Django documentation advocates the use of absolute paths, is voluntary. This is done in order to simplify expressions and to be platform independant (and it works, at least under Windows.)
1. Project "Hello World"
We will discover the workflow engine with a very simple application based on a process workflow with a single activity (a single activity, no transition: the simplest possible). This activity is to receive a message (for example, "Hello world").
- Start by creating a project django empty (or use an existing project)
Django admin-startproj myproj
- Add the following applications in the file settings.py
INSTALLED_APPS = ( ... 'django.contrib.admin', 'goflow.workflow', 'goflow.instances', )
The workflow application contains the "static" model data (modeling process), and the instances application contains the dynamic part or runtime.
- Setting up the database part of the settings file, for example like this:
DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = 'data.sqlite'
- Add the following two lines in the urls.py file:
urlpatterns = patterns ('', ... # Uncomment this for admin: (r '^ admin /', include ( 'django.contrib.admin.urls')), (r '^ workflow /', include ( 'goflow.urls')), )
- Create now the database server and start it as this:
python manage.py syncdb - pythonpath =.. python manage.py runserver - pythonpath =..
We can now open the console admin http://localhost:8000/admin, and discover the data models introduced by GoFlow:
we can also discover the GoFlow Dashboard, which has the status of workflows using a "back-office", http://localhost:8000/workflow
We will now create a process workflow.
- Return to the admin console, add an entity Process; screen below is shown:
- Take the title "Hello world", and a description
- Register using the Save button and continue editing: there is an activity End was added automatically.
- Create an initial activity, by clicking on the icon "+" in the field Initial activity: take a title, set the process on the current process "Hello world", leave the default values for other fields.
- Save
We have to create our first process workflow:
We have specified no application in our business, we will see that it is not necessary to begin to "play" with our application.
Indeed, when an activity is not associated with an application, a special application is still invoked, to simulate this activity: a panel is simply presented to the user, displaying the name and description of activity . A history of workflow is also displayed. A OK button allows you to complete the activity.
Before you start implementing our process workflow, it lacks one thing: allow the current user (admin for example) to instantiate the process.
- Add a group named Hello world, give him permission can_instantiate on the content type workflow.process, and save
- Add this group to the current user: this allows the user to instantiate the process Hello world.
Everything is now ready to execute our workflow: go on the dashboard http://localhost:8000/workflow. You will find our process and its definition, and other information on the roles and permissions
- Click on the link start a simulation instance under the process Hello world
Bugrev 21: name of process with a white
2. Let's add an activity
B answers A
TODO
3. Let's add our own models
TODO
4. Et avec du code
we will implement some forms methods.
TODO
5. GoFlow advanced
Prerequisite: use goflow svn version as version 0.5 will not work with these tutorials. You can also download the v 0.51.
(tutorial draft; screenshots will be added later)
Application unit testing
We will simulate here coding an existing application of the demo Leave: hrform.
- Launch the local server of the demo leave (cf. INSTALL.TXT file)
- Go to the admin console: http://localhost:8000/leave/admin/
- Create a LeaveRequest object: http://localhost:8000/leave/admin/leave/leaverequest/add/
- This object will be used as a model when performing unit tests; inform the beginning and end dates, type of absence, the requester (admin), and the reason (ie "test")
- On the applications panel: http://localhost:8000/leave/admin/workflow/application/
- Click on the create unit test link in the hrform application row: this will create a process with a single activity that will run the applicationhrform.
- Click on return
- Click on the start test forums link in the hrform application row; then choose the content type leave request and click OK: this will initiate as many workflow instances as LeaveRequest instances created manually before (here, only one).
- Come on the task list of th admin user: http://localhost:8000/leave/mywork/
- There must be a task for an activity called test_activity in the workflow process test_hrform
- Click on the link activate then the panel corresponding to the implementation of the hrform application will be displayed
Here we have simulated test an application in a process workflow; it seems very little, but it is important to have in mind that the activities upstream in the process are not supposed to be coded. In the development of complex workflows, and in order to work in teams, each activity should be coded and tested independently of each other.
Application automation
We are going to replace an application that requires currently a human intervention by an automatic activity. We will work on the previous application hrform and replace it with the applicationhr_auto which will execute the same treatment (in fact, this is a simplified version, because calculating the number of days worked between two dates is not trivial).
TODO