1 | """Workflow for students. |
---|
2 | """ |
---|
3 | import grok |
---|
4 | from datetime import datetime |
---|
5 | from zope.component import getUtility |
---|
6 | from hurry.workflow.workflow import Transition, WorkflowState, NullCondition |
---|
7 | from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent |
---|
8 | from waeup.kofa.interfaces import ( |
---|
9 | IObjectHistory, IKofaWorkflowInfo, IKofaUtils, |
---|
10 | CREATED, ADMITTED, CLEARANCE, REQUESTED, CLEARED, PAID, RETURNING, |
---|
11 | REGISTERED, VALIDATED, GRADUATED, TRANSCRIPT) |
---|
12 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
13 | from waeup.kofa.workflow import KofaWorkflow, KofaWorkflowInfo |
---|
14 | from waeup.kofa.students.interfaces import IStudent, IStudentsUtils |
---|
15 | from waeup.kofa.students.workflow import RegistrationWorkflowInfo |
---|
16 | |
---|
17 | |
---|
18 | REGISTRATION_TRANSITIONS = ( |
---|
19 | Transition( |
---|
20 | transition_id = 'create', |
---|
21 | title = _('Create customer'), |
---|
22 | source = None, |
---|
23 | condition = NullCondition, |
---|
24 | msg = _('Record created'), |
---|
25 | destination = CREATED), |
---|
26 | |
---|
27 | Transition( |
---|
28 | transition_id = 'admit', |
---|
29 | title = _('Approve contract'), |
---|
30 | msg = _('Contract approved'), |
---|
31 | source = CREATED, |
---|
32 | destination = ADMITTED), |
---|
33 | |
---|
34 | Transition( |
---|
35 | transition_id = 'reset1', |
---|
36 | title = _('Reset customer to initial state'), |
---|
37 | msg = _('Reset to initial state'), |
---|
38 | source = ADMITTED, |
---|
39 | destination = CREATED), |
---|
40 | |
---|
41 | Transition( |
---|
42 | transition_id = 'pay_meter_fee', |
---|
43 | title = _('Pay meter fee'), |
---|
44 | msg = _('Meter fee paid'), |
---|
45 | source = ADMITTED, |
---|
46 | destination = PAID), |
---|
47 | |
---|
48 | Transition( |
---|
49 | transition_id = 'approve_meter_fee_payment', |
---|
50 | title = _('Approve meter fee payment'), |
---|
51 | msg = _('Meter fee payment approved'), |
---|
52 | source = ADMITTED, |
---|
53 | destination = PAID), |
---|
54 | |
---|
55 | Transition( |
---|
56 | transition_id = 'reset2', |
---|
57 | title = _("Reset customer to state 'contract approved'"), |
---|
58 | msg = _("Reset to state 'contract approved'"), |
---|
59 | source = PAID, |
---|
60 | destination = ADMITTED), |
---|
61 | ) |
---|
62 | |
---|
63 | |
---|
64 | registration_workflow = KofaWorkflow(REGISTRATION_TRANSITIONS) |
---|
65 | |
---|
66 | class CustomRegistrationWorkflowInfo(RegistrationWorkflowInfo): |
---|
67 | """Adapter to adapt Student objects to workflow info objects. |
---|
68 | """ |
---|
69 | |
---|
70 | def __init__(self, context): |
---|
71 | self.context = context |
---|
72 | self.wf = registration_workflow |
---|