source: main/kofacustom.ekodisco/trunk/src/kofacustom/ekodisco/applicants/workflow.py @ 17947

Last change on this file since 17947 was 10815, checked in by Henrik Bettermann, 11 years ago

Show proper workflow states.

  • Property svn:keywords set to Id
File size: 4.3 KB
RevLine 
[10800]1## $Id: workflow.py 10815 2013-11-29 10:17:00Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""Customized workflow for applicants.
19"""
20import grok
21from hurry.workflow.workflow import Transition, WorkflowState, NullCondition
22from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent
23from waeup.kofa.applicants.interfaces import IApplicantBaseData
24from waeup.kofa.interfaces import IObjectHistory, IKofaWorkflowInfo, IKofaUtils
25from waeup.kofa.interfaces import MessageFactory as _
26from waeup.kofa.workflow import KofaWorkflow, KofaWorkflowInfo
27from waeup.kofa.applicants.workflow import ( ApplicationWorkflowInfo,
28    INITIALIZED, STARTED, SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED)
29
[10815]30
31application_states_dict = {
32    INITIALIZED: _('initialized'),
33    STARTED: _('started'),
34    SUBMITTED: _('submitted'),
35    ADMITTED: _('subscription approved'),
36    NOT_ADMITTED: _('subscription not approved'),
37    CREATED: _('customer record created'),
38    }
39
[10800]40APPLICATION_TRANSITIONS = (
41    Transition(
42        transition_id = 'init',
[10801]43        title = _('Initialize subscription'),
[10800]44        source = None,
45        condition = NullCondition,
[10801]46        msg = _('Subscription initialized'),
[10800]47        destination = INITIALIZED),
48
49    Transition(
50        transition_id = 'start',
[10801]51        title = _('Start subscription'),
52        msg = _('Subscription started'),
[10800]53        source = INITIALIZED,
54        destination = STARTED),
55
56    Transition(
57        transition_id = 'submit',
[10801]58        title = _('Submit subscription'),
59        msg = _('Subscription submitted'),
[10800]60        source = STARTED,
61        destination = SUBMITTED),
62
63    Transition(
64        transition_id = 'admit',
[10801]65        title = _('Approve subscription'),
66        msg = _('Subscription approved'),
[10800]67        source = SUBMITTED,
68        destination = ADMITTED),
69
70    Transition(
71        transition_id = 'refuse1',
[10801]72        title = _('Refuse subscription'),
73        msg = _('Subscription refused'),
[10800]74        source = SUBMITTED,
75        destination = NOT_ADMITTED),
76
77    Transition(
78        transition_id = 'refuse2',
[10801]79        title = _('Refuse subscription'),
80        msg = _('Subscription refused'),
[10800]81        source = ADMITTED,
82        destination = NOT_ADMITTED),
83
84    Transition(
85        transition_id = 'create',
86        title = _('Create student record'),
[10801]87        msg = _('Customer record created'),
[10800]88        source = ADMITTED,
89        destination = CREATED),
90
91    Transition(
92        transition_id = 'reset1',
[10801]93        title = _('Reset subscription to started'),
94        msg = _('Subscription reset'),
[10800]95        source = SUBMITTED,
96        destination = STARTED),
97
98    Transition(
99        transition_id = 'reset2',
[10801]100        title = _('Reset subscription to started'),
101        msg = _('Subscription reset'),
[10800]102        source = ADMITTED,
103        destination = STARTED),
104
105    Transition(
106        transition_id = 'reset3',
[10801]107        title = _('Reset subscription to started'),
108        msg = _('Subscription reset'),
[10800]109        source = NOT_ADMITTED,
110        destination = STARTED),
111
112    Transition(
113        transition_id = 'reset4',
[10801]114        title = _('Reset subscription to started'),
115        msg = _('Subscription reset'),
[10800]116        source = CREATED,
117        destination = STARTED),
118
119    Transition(
120        transition_id = 'reset7',
[10801]121        title = _('Reset subscription to admitted'),
122        msg = _('Subscription reset to admitted'),
[10800]123        source = CREATED,
124        destination = ADMITTED),
125    )
126
127application_workflow = KofaWorkflow(APPLICATION_TRANSITIONS)
128
129class CustomApplicationWorkflowInfo(ApplicationWorkflowInfo):
130    """Adapter to adapt Applicant objects to workflow info objects.
131    """
132
133    def __init__(self, context):
134        self.context = context
135        self.wf = application_workflow
Note: See TracBrowser for help on using the repository browser.