Changes between Initial Version and Version 1 of goflow:leave

03/25/2008 08:15:59 AM (8 years ago)

moved from goflow main page


  • goflow:leave

    v1 v1  
     1== The Leave workflow application ==
     2(not up to date)
     4Follow instructions in the [ INSTALL.TXT] file included in the [ goflow distribution].
     5You can then play with the leave demo application (available [wiki:GoFlow:demo online] too).
     7You will find here some details of the leave application implementation.
     9=== defining the workflow process ===
     10First, let's take a look at the process definition; the process is stored in the database, by using entities like Process, Activities, Transitions, Application (see workflow/, and the [ goflow data model] generated by modelviz/graphviz). In the leavedemo project, the process is dumped with the django dumpdata utility, and provided as a fixture. Typically, when you want to define a process, you will use the admin web console.
     12So, the process is the following:
     15below, the process translated as django entities, with a python syntax (it is not a real code, it's just more readable by humans):
     17Process(title='leave', begin='Begin', end='End')
     19Activity(title='Begin', application='checkstatus',
     20         pushApplication='route_to_secretary',
     21         splitMode='xor', roles=('secretary',))
     23Activity(title='Approval', application='approvalform',
     24         pushApplication='route_to_supervisor',
     25         splitMode='xor', roles=('secretary',))
     27Activity(title='Refinement', application='refine',
     28         pushApplication='route_to_customer',
     29         joinMode='xor', splitMode='xor')
     31Activity(title='UpdateHR', application='hrform',
     32         pushApplication='route_to_secretary',
     33         roles=('supervisor',))
     35Activity(title='End', application='finalinfo',
     36         pushApplication='route_to_customer',
     37         joinMode='xor', roles=('secretary',),
     38         autoFinish=False)
     41           input = 'Begin', output='Approval',
     42           condition="instance.condition=='OK: Forward to supervisor'")
     45           input = 'Begin', output='Refinement',
     46           condition="instance.condition=='Denied: Back to requester'")
     49           input = 'Approval', output='UpdateHR',
     50           condition="instance.condition=='OK: Forward to secretary'")
     53           input = 'Approval', output='Refinement',
     54           condition="instance.condition=='Denied: Back to requester'")
     57           input = 'UpdateHR', output='End')
     60           input = 'Refinement', output='End',
     61           condition="instance.condition=='Withdraw request'")
     64           input = 'Refinement', output='Begin',
     65           condition="instance.condition=='Re-request'")
     67this [ diagram] is a graphviz dot representation. It has
     68written by hand, but soon, it should be generated.
     70'''Some definitions:'''
     71[[BR]]A ''transition'' is a path from an ''Activity'' to another one.
     72[[BR]]An ''Activity'' is a task that a person (or an automatic process) with a specific role must achieve: it is linked to an ''Application'' which is typically an URL declared in the '''' file.
     73[[BR]]A ''push application'' is a handler that return a user, given the context of process instance (in fact the parameter of the handler is a ''workitem'', we will see this later)
     75=== settings file ===
     76''(a little obsolete since rev 14)''
     77==== standard settings ====
     78First, tell Django you want to use the workflow engine:
     81    ....
     82    'leavedemo.leave',     # the leave application
     83    'goflow.workflow',     # goflow workflow engine
     87If you use ''send_mail'' application, you should define these:
     89DEFAULT_FROM_EMAIL = email sender
     90EMAIL_HOST = smtp server
     92==== specific settings ====
     95WF_APPS_PREFIX = 'leavedemo'
     97This is the url prefix for workflow application definition;
     98for example, in the workflow definition the application ''app1'' is
     99mapped on the url ''/leavedemo/app1''
     102WF_PUSH_APPS_PREFIX = 'leavedemo.leave.pushapplications'
     104this is the module containing the push applications functions;
     105for example, the push application ''pushapp1'' is a function defined as
     106following in the ''leavedemo/leave/'' module:
     108def pushapp1(workitem):
     109    ...
     110    return aUser
     113If you use ''send_mail'' application, you should define these:
     115EMAIL_SUBJECT_PREFIX = '[Goflow notification]'
     118=== file ===
     120==== Starting a workflow instance ====
     122the ''start_application'' is a handler that display a form used to create an instance of the workflow process:
     126    (r'^leave/start/(app)/(model)/$', 'goflow.workflow.applications.start_application'),
     128This above is the simplest way to start: the default process has the same name as app, and the default template used is "start_[model].html".
     130other usage:
     132    (r'^leave/request/$',
     133     'goflow.workflow.applications.start_application',
     134     {'process_name':'leave', 'form_class':RequestForm, 'template':'start_leave.html'}),
     138see ''workflow urls'' below: an instance can be started with just a model (see also leave demo)
     140==== Simple info application ====
     141the only parameter is a template; this application just shows an inf panel to a user.
     143    (r'^leave/finalinfo/$', 'goflow.workflow.applications.simple_application', {'template':'finalinfo.html'}),
     147==== Form application ====
     148this application displays a form to the user: by clicking on a submit button, the activity is terminated with
     149 the instance condition set to the submit button value (label displayed)
     151    (r'^leave/checkstatus/$', 'goflow.workflow.applications.application_form', {'form_class':ApprovalForm,
     152                                                                                'template':'checkstatus.html',
     153                                                                                'submit_name':'approval'}),
     156==== Custom applications ====
     157for more advanced usages, you may write your own applications: for this, take a look at the application form code (see above) and copy-paste the code in your project (in an file) and customize it; one advantage is that the file can be quite simpler (less parameters on the application url line).
     160=== workflow urls ===
     161Some urls are workflow standard tasks,  managed by the engine itself; like CRUD urls managed by admin,  the workflow standard tasks  are available with the following line in the '''' file:
     163    (r'^leave/', include('goflow.workflow.urls')),
     166So the workflow engine provides handlers and default templates below:
     168    (r'^mywork/$', 'goflow.workflow.views.mywork', {'template':'mywork.html'}),
     169    (r'^otherswork/$', 'goflow.workflow.views.otherswork', {'template':'otherswork.html'}),
     170    (r'^otherswork/instancehistory/$', 'goflow.workflow.views.instancehistory', {'template':'instancehistory.html'}),
     171    (r'^myrequests/$', 'goflow.workflow.views.myrequests', {'template':'myrequests.html'}),
     172    (r'^myrequests/instancehistory/$', 'goflow.workflow.views.instancehistory', {'template':'instancehistory.html'}),
     173    (r'^mywork/activate/$', 'goflow.workflow.views.activate', {'template':'activate.html'}),
     174    (r'^mywork/complete/$', 'goflow.workflow.views.complete', {'template':'complete.html'}),
     175    (r'^start/(?P<app_label>.*)/(?P<model_name>.*)/$', 'goflow.workflow.applications.start_application'),
     176    (r'^cron/$','django.contrib.workflow.views.cron'),
     179 * ''mywork'': displays the tasks list of the current user
     180 * ....
     181 * ''start'': start a new instance given a model
     182 * ''cron'': cron simulation task for timeout management
     184''next soon''
     186=== Application templates ===
     187You can (may) redefine the templates associated with standard workflow views.
     189For each application, a specific template has to be built. The context available has following variales:
     190  * ''form'': form (newforms framework)
     191  * ''instance'': instance object
     192  * ''ob'': object (application-defined) linked to instance
     193  * ''instance_props'': properties of instance
     195The application developper should insert submit input fields when he inserts forms; the ''application_form'' handler then will update ''instance.condition'' with the value of the submit button pressed.
Back to Top