Changes between Version 40 and Version 41 of GoFlow


Ignore:
Timestamp:
03/25/08 08:14:43 (7 years ago)
Author:
goflow
Comment:

leave app move to a specific page

Legend:

Unmodified
Added
Removed
Modified
  • GoFlow

    v40 v41  
    1414
    1515== Sites ==
    16   * [http://django-goflow.blogspot.com/ Goflow (french) blog]
     16  * [http://django-goflow.blogspot.com/ Goflow (french) blog (pas à jour)]
    1717  * [wiki:GoFlow:demo Leave demo online]
    18   * [https://opensvn.csie.org/goflow/trunk/ svn] (new goflow trunk)
    19   * [https://opensvn.csie.org/openflow/branches/django_contrib/ svn] (django_contrib branch, ''obsolete'')
    20   * [https://opensvn.csie.org/traccgi/openflow Goflow trac] ''obsolete''
    21 
     18  * [https://opensvn.csie.org/goflow/trunk/ svn] (goflow trunk)
    2219  * contact: ''goflow(at)alwaysdata.net''
    2320
    24 == The Leave workflow application ==
    25 Follow instructions in the [https://opensvn.csie.org/goflow/trunk/INSTALL.TXT INSTALL.TXT] file included in the [https://opensvn.csie.org/goflow/trunk/goflow goflow distribution].
    26 You can then play with the leave demo application (available [wiki:GoFlow:demo online] too).
    27  
    28 You will find here some details of the leave application implementation.
     21== Goflow applications ==
     22  * [wiki:goflow:leave Leave] (clone of OpenFlow demo application)
    2923
    30 === defining the workflow process ===
    31 First, 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/models.py, and the [http://goflow.alwaysdata.net/images/workflow.png 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.
    32 
    33 So, the process is the following:
    34 http://goflow.alwaysdata.net/leavedemo/media/img/leaveactivities.png
    35 
    36 below, the process translated as django entities, with a python syntax (it is not a real code, it's just more readable by humans):
    37 {{{
    38 Process(title='leave', begin='Begin', end='End')
    39 
    40 Activity(title='Begin', application='checkstatus',
    41          pushApplication='route_to_secretary',
    42          splitMode='xor', roles=('secretary',))
    43 
    44 Activity(title='Approval', application='approvalform',
    45          pushApplication='route_to_supervisor',
    46          splitMode='xor', roles=('secretary',))
    47 
    48 Activity(title='Refinement', application='refine',
    49          pushApplication='route_to_customer',
    50          joinMode='xor', splitMode='xor')
    51 
    52 Activity(title='UpdateHR', application='hrform',
    53          pushApplication='route_to_secretary',
    54          roles=('supervisor',))
    55 
    56 Activity(title='End', application='finalinfo',
    57          pushApplication='route_to_customer',
    58          joinMode='xor', roles=('secretary',),
    59          autoFinish=False)
    60 
    61 Transition(name='send_to_approval',
    62            input = 'Begin', output='Approval',
    63            condition="instance.condition=='OK: Forward to supervisor'")
    64 
    65 Transition(name='send_to_refinement',
    66            input = 'Begin', output='Refinement',
    67            condition="instance.condition=='Denied: Back to requester'")
    68 
    69 Transition(name='request_approved',
    70            input = 'Approval', output='UpdateHR',
    71            condition="instance.condition=='OK: Forward to secretary'")
    72 
    73 Transition(name='not_approved',
    74            input = 'Approval', output='Refinement',
    75            condition="instance.condition=='Denied: Back to requester'")
    76 
    77 Transition(name='tell_employee',
    78            input = 'UpdateHR', output='End')
    79 
    80 Transition(name='cancel_request',
    81            input = 'Refinement', output='End',
    82            condition="instance.condition=='Withdraw request'")
    83 
    84 Transition(name='re_request',
    85            input = 'Refinement', output='Begin',
    86            condition="instance.condition=='Re-request'")
    87 }}}
    88 this [http://goflow.alwaysdata.net/images/leave.png diagram] is a graphviz dot representation. It has
    89 written by hand, but soon, it should be generated.
    90 
    91 '''Some definitions:'''
    92 [[BR]]A ''transition'' is a path from an ''Activity'' to another one.
    93 [[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 ''urls.py'' file.
    94 [[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)
    95 
    96 === settings file ===
    97 ''(a little obsolete since rev 14)''
    98 ==== standard settings ====
    99 First, tell Django you want to use the workflow engine:
    100 {{{
    101 INSTALLED_APPS = (
    102     ....
    103     'leavedemo.leave',     # the leave application
    104     'goflow.workflow',     # goflow workflow engine
    105 )
    106 }}}
    107 
    108 If you use ''send_mail'' application, you should define these:
    109 {{{
    110 DEFAULT_FROM_EMAIL = email sender
    111 EMAIL_HOST = smtp server
    112 }}}
    113 ==== specific settings ====
    114 
    115 {{{
    116 WF_APPS_PREFIX = 'leavedemo'
    117 }}}
    118 This is the url prefix for workflow application definition;
    119 for example, in the workflow definition the application ''app1'' is
    120 mapped on the url ''/leavedemo/app1''
    121 
    122 {{{
    123 WF_PUSH_APPS_PREFIX = 'leavedemo.leave.pushapplications'
    124 }}}
    125 this is the module containing the push applications functions;
    126 for example, the push application ''pushapp1'' is a function defined as
    127 following in the ''leavedemo/leave/pushapplications.py'' module:
    128 {{{
    129 def pushapp1(workitem):
    130     ...
    131     return aUser
    132 }}}
    133 
    134 If you use ''send_mail'' application, you should define these:
    135 {{{
    136 EMAIL_SUBJECT_PREFIX = '[Goflow notification]'
    137 }}}
    138 
    139 === urls.py file ===
    140 
    141 ==== Starting a workflow instance ====
    142 
    143 the ''start_application'' is a handler that display a form used to create an instance of the workflow process:
    144 
    145 usage:
    146 {{{
    147     (r'^leave/start/(app)/(model)/$', 'goflow.workflow.applications.start_application'),
    148 }}}
    149 This 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".
    150 
    151 other usage:
    152 {{{
    153     (r'^leave/request/$',
    154      'goflow.workflow.applications.start_application',
    155      {'process_name':'leave', 'form_class':RequestForm, 'template':'start_leave.html'}),
    156 }}}
    157 
    158 ''New:''
    159 see ''workflow urls'' below: an instance can be started with just a model (see also leave demo)
    160 
    161 ==== Simple info application ====
    162 the only parameter is a template; this application just shows an inf panel to a user.
    163 {{{
    164     (r'^leave/finalinfo/$', 'goflow.workflow.applications.simple_application', {'template':'finalinfo.html'}),
    165 }}}
    166 
    167 
    168 ==== Form application ====
    169 this application displays a form to the user: by clicking on a submit button, the activity is terminated with
    170  the instance condition set to the submit button value (label displayed)
    171 {{{
    172     (r'^leave/checkstatus/$', 'goflow.workflow.applications.application_form', {'form_class':ApprovalForm,
    173                                                                                 'template':'checkstatus.html',
    174                                                                                 'submit_name':'approval'}),
    175 }}}
    176 
    177 ==== Custom applications ====
    178 for 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 applications.py file) and customize it; one advantage is that the urls.py file can be quite simpler (less parameters on the application url line).
    179 
    180 
    181 === workflow urls ===
    182 Some 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 ''urls.py'' file:
    183 {{{
    184     (r'^leave/', include('goflow.workflow.urls')),
    185 }}}
    186 
    187 So the workflow engine provides handlers and default templates below:
    188 {{{
    189     (r'^mywork/$', 'goflow.workflow.views.mywork', {'template':'mywork.html'}),
    190     (r'^otherswork/$', 'goflow.workflow.views.otherswork', {'template':'otherswork.html'}),
    191     (r'^otherswork/instancehistory/$', 'goflow.workflow.views.instancehistory', {'template':'instancehistory.html'}),
    192     (r'^myrequests/$', 'goflow.workflow.views.myrequests', {'template':'myrequests.html'}),
    193     (r'^myrequests/instancehistory/$', 'goflow.workflow.views.instancehistory', {'template':'instancehistory.html'}),
    194     (r'^mywork/activate/$', 'goflow.workflow.views.activate', {'template':'activate.html'}),
    195     (r'^mywork/complete/$', 'goflow.workflow.views.complete', {'template':'complete.html'}),
    196     (r'^start/(?P<app_label>.*)/(?P<model_name>.*)/$', 'goflow.workflow.applications.start_application'),
    197     (r'^cron/$','django.contrib.workflow.views.cron'),
    198 }}}
    199 
    200  * ''mywork'': displays the tasks list of the current user
    201  * ....
    202  * ''start'': start a new instance given a model
    203  * ''cron'': cron simulation task for timeout management
    204 
    205 ''next soon''
    206 
    207 === Application templates ===
    208 You can (may) redefine the templates associated with standard workflow views.
    209 
    210 For each application, a specific template has to be built. The context available has following variales:
    211   * ''form'': form (newforms framework)
    212   * ''instance'': instance object
    213   * ''ob'': object (application-defined) linked to instance
    214   * ''instance_props'': properties of instance
    215 
    216 The 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